I am trying to make my table and buttons to be responsive but without success.
The buttons aren't fixed to the width when I decrease the size of the screen and the table below is set behind of this buttons and not below as it should be.
The search bar and buttons are supposed to be fixed below the navbar.
The system is like an admin system, where I display the logs from my other system (getting the data from MongoDB).
I am attaching screenshots and source code.
HTML-
<header>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="#">
<img src="./image/logoC.png">
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><i class="fa fa-sign-in fa-fw"></i>Logins
</li>
<li><i class="fa fa-user-plus fa-fw"></i>Signup
</li>
<li><i class="fa fa-exclamation-circle fa-fw"></i>Add Items Errors
</li>
<li><i class="fa fa-retweet fa-fw"></i>Refresh Log
</li>
<li>Refresh Errors
</li>
<li>Bad Product
</li>
<li><i class="fa fa-refresh fa-fw"></i>Refresh All
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><i class="fa fa-sign-out fa-fw"></i>Logout</li>
</ul>
</div>
</div>
</div>
</header>
<div class="table_content">
<div class="row">
<div class="options">
<div class="col-sm-4">
<form class="searchBox">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i>
</div>
<input type="text" class="form-control" ng-model="searchLogins">
</div>
</div>
</form>
</div>
<div class="col-sm-8">
<ul class="pager" ng-show="currentPage==login">
<li>
<button id="markAsHandled" name="markAsHandled" class="btn btn-success" ng-click="handle()" value="Handle">Mark as Handled</button>
</li>
<li>
<button id="deleteError" name="deleteError" class="btn btn-danger" ng-click="remove()" value="Remove">Delete Errors</button>
</li>
<li>
<button id="select_all" name="deleteError" class="btn btn-info" ng-model="selectedAll" ng-click="checkAll()">Select All</button>
</li>
<li>
<button ng-click="removeLogs()" id="deleteAllErrors" name="deleteError" class="btn btn-danger">Remove All</button>
</li>
</ul>
<h5 id="statusMessage">{{statusMsg}}</h5>
</div>
</div>
</div>
</div>
<div class="tableAdmin">
<table ng-table="tableParams" class="table table-striped" show-filter="true">
<tr ng-repeat="log in $data| orderBy:sortType:sortReverse | filter : searchLogins">
<td data-title="'ID'">
{{log._id}}
</td>
<td data-title="'Data'">
{{log.logData}}
</td>
<td data-title="'Date'">
{{log.logDate}}
</td>
<td data-title="'Handled'">
<input type="checkbox" ng-model="log.selected" />
</td>
</tr>
</table>
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="span9">
<p class="text-muted">Copyright © 2017 - Designed & Developed by me.</p>
</div>
</div>
</div>
</footer>
</div>
CSS-
html {
width: 100%;
height: 100%;
}
body {
font-family: 'Lato', Calibri, Arial, sans-serif;
background: #f9f9f9;
font-weight: 300;
font-size: 15px;
overflow: scroll;
overflow-x: hidden;
width: 100%;
height: 100%;
}
.btn {
font-weight: 400;
width: 100px;
height: 36px;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
#markAsHandled {
width: 130px;
margin-right: 5px;
float: left;
}
#deleteError {
width: 110px;
margin-right: 5px;
float: left;
}
#select_all {
width: 110px;
margin-right: 15px;
float: left;
}
#deleteAllErrors {
width: 110px;
float: left;
}
#statusMessage {
float: left;
margin-left: 10px;
padding-top: 10px;
}
.table {
width: 80%;
height: 100%;
margin-top: 55px;
margin-left: 6px;
}
#ID_column {
width: 230px;
}
#user_column {
width: 230px;
}
#date_column {
width: 230px;
}
#handled_column {
width: 100px;
}
input[type="radio"],
input[type="checkbox"] {
line-height: normal;
margin-left: 50px;
}
.btn-success {
margin-left: 26px;
width: 100px;
}
#import url(http://fonts.googleapis.com/css?family=Lato:300,400,700);
*,
*:after,
*:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
margin: 0;
}
.ckbox {
position: relative;
}
.ckbox input[type="checkbox"] {
opacity: 0;
}
.table_content {
width: 100%;
margin-top: 66px;
}
td {
word-wrap: break-word;
overflow-wrap: break-word;
}
.searchBox {
float: left;
width: 400px;
margin: 10px 0 0 0;
}
/*Menu Options*/
.options {
float: left;
width: 100%;
height: 50px;
position: fixed;
display: block;
padding-left: 10px;
background-color: #f9f9f9;
z-index: 1000;
}
.pager {
float: left;
margin: 10px 0 0 10px;
}
.tableAdmin {
width: 100%;
padding-top: 20px;
padding-left: 50px;
}
.badgebox {
opacity: 0;
}
.badgebox + .badge {
text-indent: -999999px;
width: 27px;
}
.badgebox:focus + .badge {
box-shadow: inset 0px 0px 5px;
}
.badgebox:checked + .badge {
text-indent: 0;
}
#div1 {
height: 50px;
width: 100%;
margin-left: 35%;
}
footer {
padding: 50px 0;
height: auto;
text-align: center;
}
Thank you guys.
I've fixed this issue by decreasing the size of the search area and the size of the buttons.
Related
I am generating a coupon type display by html and css without creating and storing the real image on server to save space.
Plan is to display it and get it printed out when user wants to print. I have managed to create the layout by HTML and css and it displays as follows,
But when the Print Now button is clicked there are so much blank space created towards the left side, please see the image below,
I can not figure out what might be the issue here, I am attaching the HTML and CSS below.
HTML
<div class="print-coupon-text">
<div class="pct-heading">
<img src="***image-source***" alt="Created by JAiCOUPONS" />
</div>
<div class="pct-col pct-col-1">
<div class="pct-store-logo">
<img src="***image-source***" alt="Coupon Store" />
</div>
<div class="pct-store-desc">
<span>http://abcdexample.com</span>
<span>#2333, 1st Comfort Road</span>
<span>Redint TF 78999</span>
<span>210 Price Fork Road</span>
<span>Redint TF 78999</span>
<span>(333) 323-4444</span>
</div>
</div>
<div class="pct-col pct-col-2">
<span class="pct-offer-1">$50</span>
<span class="pct-offer-2">Off</span>
<span class="pct-offer-3"> Free Icecream </span>
</div>
<div class="pct-col pct-col-3">
<span class="pct-title">Buy 1 Dinner</span>
<span class="pct-title pct-title-end">And get the 2nd one Free</span>
<span class="pct-desc">Dine In, Carryout Only</span>
<span class="pct-desc">Excludes buffet with this coupon</span>
<span class="pct-desc">Not Valid with other Offers</span>
<span class="pct-desc">Expires : 15th Jan</span>
</div>
<div class="pct-footer">
<span class="pct-footer-1">Contact JAiCOUPONS # (972) 301-7898</span>
<span class="pct-footer-2">Coupon ID **** | ©JAiCOUPONS.com</span>
</div>
</div>
CSS
.print-coupon-text {
position: relative;
width: 100%;
float: left;
margin-bottom: 10px;
padding: 10px;
border: 1px dashed #000;
border-radius: 10px;
font-size: 10px;
text-align: left;
}
.pct-col {
width: 30%;
float: left;
margin: 0 8px;
}
.pct-store-desc span, .pct-footer span, .pct-desc {
display: block;
}
.pct-col.pct-col-2 {
padding-left: 5px;
padding-top: 85px;
}
.pct-col.pct-col-3 {
padding-top: 40px;
}
.pct-offer-1 {
font-size: 60px;
font-weight: bold;
}
.pct-offer-2 {
font-weight: bold;
}
.pct-offer-3 {
display: block;
}
.pct-title {
display: block;
font-size: 13px;
}
.pct-title-end {
border-bottom: 1px dotted;
padding-bottom: 5px;
}
.pct-store-logo img {
width: 150px;
height: 85px;
}
.pct-heading {
position: absolute;
top: 0px;
left: 28%;
}
.pct-heading img {
width: 90%;
}
.pct-footer-1 {
position: absolute;
bottom: 16px;
right: 6px;
}
.pct-footer-2 {
position: absolute;
bottom: 0px;
right: 6px;
}
#media print {
body * {
visibility: hidden;
}
.print-coupon-text, .print-coupon-text * {
visibility: visible;
}
.print-coupon-text {
position: absolute;
left: 0;
top: 0;
}
}
Any help is appreciated.
UPDATE
Initial display is coming on the pop up.
I think you should give fixed width to your div.print-coupon-text
.print-coupon-text{
width: 700px; // or greater/less
}
Hi try displaying the coupon in its own page, you won't have this issue in that case. check screenshots below.
BTW, i was not able to replicate your issue, working fine for me with your code.
EDIT :: Tried using Bootstrap Popup as well, working fine.
.print-coupon-text {
position: relative;
width: 100%;
float: left;
margin-bottom: 10px;
padding: 10px;
border: 1px dashed #000;
border-radius: 10px;
font-size: 10px;
text-align: left;
}
.pct-col {
width: 30%;
float: left;
margin: 0 8px;
}
.pct-store-desc span,
.pct-footer span,
.pct-desc {
display: block;
}
.pct-col.pct-col-2 {
padding-left: 5px;
padding-top: 85px;
}
.pct-col.pct-col-3 {
padding-top: 40px;
}
.pct-offer-1 {
font-size: 60px;
font-weight: bold;
}
.pct-offer-2 {
font-weight: bold;
}
.pct-offer-3 {
display: block;
}
.pct-title {
display: block;
font-size: 13px;
}
.pct-title-end {
border-bottom: 1px dotted;
padding-bottom: 5px;
}
.pct-store-logo img {
width: 150px;
height: 85px;
}
.pct-heading {
position: absolute;
top: 0px;
left: 28%;
}
.pct-heading img {
width: 90%;
}
.pct-footer-1 {
position: absolute;
bottom: 16px;
right: 6px;
}
.pct-footer-2 {
position: absolute;
bottom: 0px;
right: 6px;
}
#media print {
body * {
visibility: hidden;
}
.print-coupon-text,
.print-coupon-text * {
visibility: visible;
}
.print-coupon-text {
position: absolute;
left: 0;
top: 0;
}
}
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Popup</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<div class="print-coupon-text">
<div class="pct-heading">
<img src="***image-source***" alt="Created by JAiCOUPONS" />
</div>
<div class="pct-col pct-col-1">
<div class="pct-store-logo">
<img src="***image-source***" alt="Coupon Store" />
</div>
<div class="pct-store-desc">
<span>http://abcdexample.com</span>
<span>#2333, 1st Comfort Road</span>
<span>Redint TF 78999</span>
<span>210 Price Fork Road</span>
<span>Redint TF 78999</span>
<span>(333) 323-4444</span>
</div>
</div>
<div class="pct-col pct-col-2">
<span class="pct-offer-1">$50</span>
<span class="pct-offer-2">Off</span>
<span class="pct-offer-3"> Free Icecream </span>
</div>
<div class="pct-col pct-col-3">
<span class="pct-title">Buy 1 Dinner</span>
<span class="pct-title pct-title-end">And get the 2nd one Free</span>
<span class="pct-desc">Dine In, Carryout Only</span>
<span class="pct-desc">Excludes buffet with this coupon</span>
<span class="pct-desc">Not Valid with other Offers</span>
<span class="pct-desc">Expires : 15th Jan</span>
</div>
<div class="pct-footer">
<span class="pct-footer-1">Contact JAiCOUPONS # (972) 301-7898</span>
<span class="pct-footer-2">Coupon ID **** | ©JAiCOUPONS.com</span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I am able to make my text in the center but using px values. When I try using percentage it is not working. I tried display:table; and display:table-cell and also display:flex;
justify-content: center; //horizontal centering
align-items:center; but it did not work.
My parent div has height: 7.7% .
Note: I have updated my full header code
Below is JSFIDDLE link:
https://jsfiddle.net/Anthony_Chien/f7n77068/#&togetherjs=gR8VEaLgqR
HTML:
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS</span>
</div>
<div class="navheadersec2">
<div class="navheadermargin">
<div class="btn-group">
<button class="btn btn-default btn-md dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="headerspanbox"> <div class="headerdivbox"></div> </span>Default <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</div>
<!--<div class="header-icons">
<span class="icons-group"><img src="assets/images/icons/undo.png" /></span>
<span class="icons-label">Undo</span>
</div>-->
<span class="btn-group icons-grp"><img src="assets/images/icons/undo.png" /><br>Undo</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/redo.png" /><br>Redo</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/zoom-in.png" /><br></span>
<span class="btn-group icons-grp"><img src="assets/images/icons/zoom-out.png" /><br></span>
<span class="btn-group icons-grp"><img src="assets/images/icons/group.png" /><br>Group</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/pattern.png" /><br>Pattern</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/lock.png" /><br>Lock</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/select.png" /><br>Select</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/resize.png" /><br>Scale</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/rotate.png" /><br>Rotate</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/rotate.png" /><br>Forward</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/backward.png" /><br>Backward</span>
<span class="btn-group icons-grp"><img src="assets/images/icons/panel.png" /><br>Panel</span>
</div>
</div>
<div class="navheadersec3">
<div class="navheadermargin">
<div class="headersec3para">
<p class="headerpara">Code</p>
<p class="headerpara">Some text</p>
</div>
<p class="header-price">2,550</p>
<span class="btn-group icons-grp info-icon"><img src="assets/images/icons/info.png" /></span>
<p class="header-price add-to-cart">ADD</p>
</div>
</div>
</nav>
</div>
CSS:
.vav-main{
width: 100%;
height: 100%;
}
.navheader{
width: 100%;
height: 7.7%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
width: 5%;
height: 100%;
background-color: #ffffff;
position:relative; /* Add this property */
transform:translate(-50% -50%); /* Add this property */
top:50%; /* Add this property */
left:50%; /* Add this property */
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.navheadersec2 {
width: 64.76%;
display: inline-block;
border-right: solid 1px #b8b8b8;
height: 100%;
}
.navheadersec3{
width: 30.214%;
display: inline-block;
margin-left: -4px;
}
.navheadermargin .headersec3para{
width: 30.53%;
height: 100%;
float: left;
margin-left: 6.10%;
}
.headersec3para .headerpara:first-child{
font-size: 12px;
margin: 0px !IMPORTANT;
font-weight: bold;
}
.headersec3para .headerpara{
font-size: 10px;
margin: 0px !IMPORTANT;
}
.header-price{
margin: 0px;
height: 100%;
width: 16.03%;
float: left;
text-align: center;
line-height: 34px;
font-weight: bold;
font-size: 18px;
font-family: SourceSansPro;
}
.info-icon{
margin: auto;
text-align: center;
line-height: 34px;
}
.info-icon > img{
width: 20px;
height: 20px;
}
.add-to-cart{
width: 30.534%;
font-size: 15px;
color: #009cff;
}
.navheadermargin{
margin-top: 10px;
height: 34px;
margin-bottom: 10px;
}
.navheadermargin .btn-group{
margin-left: 1.3%;
height: 100%;
width: 13.510%;
float: left;
}
.navheadermargin .header-icons{
float: left;
width: 24px;
height: 100%;
}
.header-icons .icons-group{
height: 21px;
}
.header-icons .icons-group img{
height: 20px;
width: 20px;
}
.header-icons .icons-label{
height: 15px;
font-family: SourceSansPro;
font-size: 10px;
}
.navheadermargin .btn-group button{
height: 100%;
width: 100%;
}
.headerspanbox{
display: inline-block;
}
.headerspanbox .headerdivbox{
background-color: #1fb6ff;
margin-right: 10px;
height: 14px;
width: 18px;
}
Screenshot Image:
.vav-main{
width: 100%;
height: 100%;
}
.navheader{
width: 100%;
height: 7.7%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
width: 5%;
height: 100%;
background-color: #ffffff;
position:relative; /* Add this property */
transform:translate(-50% -50%); /* Add this property */
top:50%; /* Add this property */
left:50%; /* Add this property */
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.vav-main> .navbar {
margin-bottom: 0px;
min-height:initial;
}
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS....</span>
</div>
</nav>
</div>
You can use flex for achieve the same.
update fiddle below
working fiddle
.vav-main{
width: 100%;
height: 100%;
}
.navheader{
width: 100%;
height: 7.7%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
height: 100%;
width:100%;
background-color: #ffffff;
display:flex;
justify-content:center;
align-items:center;
flex-flow:column nowrap;
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.navlogo span a {
align-self:center;
}
.vav-main> .navbar {
margin-bottom: 0px;
min-height:initial;
}
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS....</span>
</div>
</nav>
</div>
You can use display: table; on your container, and display: table-cell; on your children, to center vertically and horizontally your navigation elements. Ypu can then set container and elements width based on the layout you need.
Possible example :
.vav-main{
position: relative;
width: 100%;
height: 100%;
}
.navbar{
display: table;
width: 100%;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
height: 100;
background-color: #ffffff;
width: 5%;
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
}
.navbar-header {
display: table-cell;
padding: 3.5%;
vertical-align: middle;
text-align: center;
}
<div class="vav-main">
<nav class="navbar navbar-default">
<div class="navbar-header navlogo">
<span>DS</span>
</div>
<div class="navbar-header">
........
</div>
</nav>
</div>
.navheader{
width: 100%;
height: 100px;
background-color: #ffffff;
border: solid 1px #b8b8b8;
}
.navlogo {
width: 5%;
height: 100%;
background-color: #ffffff;
}
.navlogo span {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
display:table;height:100%;width:100px;
}
.navlogo span a{
display:table-cell;vertical-align:middle;text-align:center;margin:0;
}
<div class="vav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
<span>DS</span>
</div>
</nav>
</div>
Might be you are doing that using bootstrap if so then you could try it like as below, remove span tag as both a and span tags are inline elements, so you could use one if needed.
.nav-main {
width: 100%;
height: 100%;
}
.nav-main > .navheader {
width: 100%;
height: 7.7%;
background-color: #ffffff;
}
.navlogo {
width: 100%;
height: 100%;
background-color: #ffffff;
text-align: center;
}
.navlogo > a {
font-family: SourceSansPro;
font-size: 24px;
font-weight: bold;
display: inline-block;
margin-top: 8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="nav-main">
<nav class="navbar navbar-default navheader">
<div class="navbar-header navlogo">
DS
</div>
<div>
</div>
</nav>
</div>
I don't modify on your code, I just write tinny block of code. Hope this will be helpful for you. As you see, the text inside lime block always align center by horizonal and middle by vertical.
$('#header .text').css('left', 'calc(50% - '+$('#header .text').css('width')+' / 2)');
$('#header .text').css('top', 'calc(50% - '+$('#header .text').css('height')+' / 2)');
#header{
width:100%;
height:200px;
border:1px blue solid;
}
#box{
width:30%;
height:80%;
background-color:lime;
text-align:center;
position:relative;
}
#box .text{
border:1px red solid;
position:absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='header'>
<div id='box'>
<div class='text'>abchghjghj</div>
</div>
</div>
All are working however in 800 px, 1100px, 1400px , the navigation bar is not showing up as I think that the 400 px media query have overlapped others queries. I need help on how to make navigation bar show up ...
CSS Code:
#media screen and (min-width: 400px)
{
header {
padding: 1%;
}
header h1 {
position: relative;
left: 0.5%;
bottom: 10%;
}
header div{
display: none;
}
nav.sitenavigation {
}
nav.sitenavigation ul {
border: 3px solid #34180f;
display: none;
background-color: #B8944D;
position: absolute;
right: 5%;
top: 80%;
z-index: 1;
}
nav.sitenavigation ul li {
display: inline-block;
}
.navigation-menu-button {
float: right;
}
article.container{
padding:0%;
}
figure {
display: none;
}
aside {
display: none;
}
aside p {
display: none;
}
}
#media screen and (min-width:800px),print
{
header h1 {
position: absolute;
top: 8%;
left: 28.0%;
}
header div{
display: inline;
position: relative;
right: 39%;
}
nav.sitenavigation {
position: relative;
bottom: 2%;
padding: 0.3%;
}
.navigation-menu-button {
display:none;
}
ul li {
display:inline;
margin-right: 2%;
position: relative;
left: 36.5%;
}
article {
width: 62.6%;
padding: 2%;
}
article p {
padding-right: 0%;
}
#contentstart {
padding-right: 0%;
}
figure {
display: none;
}
aside {
display: inline;
}
aside p {
position: relative;
left: 3.5%;
margin: 2% 0 0 5%;
padding-right: 5%;
}
}
#media screen and (min-width:1100px){
header h1 {
position: absolute;
top: 5.5%;
left: 37%;
}
header div {
display: inline;
position: relative;
right: 39%;
}
nav.sitenavigation {
position: relative;
bottom: 2%;
padding: 0.3%;
}
.navigation-menu-button {
display:none;
}
ul li {
display:inline;
margin-right: 2%;
position: relative;
left: 43.5%;
}
article {
width: 62.6%;
padding: 2%;
}
article p {
padding-right: 50%;
}
#contentstart {
padding-right: 50%;
}
figure {
position: absolute;
left: 50%;
bottom: 28.7%;
margin: 2% 2% 0 0.3%;
}
aside {
display: inline;
width: 30%;
}
aside p {
position: relative;
left: 3%;
padding: 2% 6% 0 6%;
margin: 1% 0 0 0%;
}
}
#media screen and (min-width:1400px) {
body {
width: 1400px;
}
header h1 {
position: absolute;
top: 7%;
left: 42%;
}
header div {
display: inline;
position: relative;
right: 39%;
}
nav.sitenavigation {
position: relative;
bottom: 2%;
padding: 0.3%;
}
ul li {
display:inline;
margin-right: 2%;
position: relative;
left: 47.1%;
}
article {
width: 62.6%;
padding: 2%;
}
article p {
padding-right: 54%;
padding-bottom: 2%;
}
figure {
position: absolute;
left: 45%;
bottom: 1%;
top: 0.2%;
margin: 2%;
}
aside {
display: inline;
width: 30%;
}
aside p {
position: relative;
left: 3%;
padding: 2% 6% 0 6%;
padding-right: 7%;
margin: 1% 0 0 0%;
}
}
HTML Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Revisions Bookstore & Cafe</title>
<!--
Revisions Bookstore and Cafe main web page
Filename: index.html
Author: Wong Wan Zhen Sofia
Date: 5 January 2017
HTML5 and CSS3 Illustrated Unit I, Visual Workshop
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="modernizr.custom.40753.js"></script>
<link rel="stylesheet" href="styles.css">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="icon" sizes="192x192" href="images/android.png">
</head>
<body>
<div class="container">
<p class="skipnavigation">Skip navigation </p>
<header>
<h1>Revisions Bookstore & Cafe</h1>
<div>
<img src="images/logo.gif" width="120" height="100" alt="">
</div>
</header>
<nav class="sitenavigation">
<div class="navigation-menu-button">
<img src="images/menu.png" width = "60" height="60" alt="Show Navigation">
</div>
<ul>
<li>Home</li>
<li>Events</li>
<li>New Releases</li>
</ul>
</nav>
<article>
<div class="container">
<h2 id="contentstart">10th Anniversary Sale!</h2>
<figure><img src="images/browsing.jpg" width="500" height = "378" alt="picture of person browsing"></figure>
<p>10% off our top 10 best sellers</p>
<p>Buy any two books, get a third at 50% off</p>
<p>In-store giveaways every day this month</p>
<p>Through November 30</p>
</div>
</article>
<aside>
<p>Custom brewed coffee and hand-selected books.</p>
<p>Special orders are our specialty.</p>
</aside>
<footer>
<p>412 N. 25th St.</p>
<p>Richmond, VA 23223</p>
<p>(804) 555-2565</p>
</footer>
</div>
<script src ="script.js"></script>
</body>
</html>
Try to use bootstrap for responsive and mobile-first. Quickly demo for you.
HTML:
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<!-- Logo -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mainNavBar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
COLLAPSE NAVBAR
</div>
<!-- Menu Items -->
<div class="collapse navbar-collapse" id="mainNavBar">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<!--<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">-->
<!--<div class="input-group" id="wm_btn_cholai">-->
<!--<i class="glyphicon glyphicon-repeat"></i> Cho lại-->
<!--</div>-->
<!--</div>-->
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="input-group" id="wm_btn_boqua">
<i class="glyphicon glyphicon-refresh"></i> Bỏ qua
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="input-group" id="wm_btn_new">
<i class="glyphicon glyphicon-floppy-saved"></i> Thêm Mới
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="input-group" id="wm_btn_sua">
<i class="glyphicon glyphicon-edit"></i> Sửa
</div>
</div>
<!--<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">-->
<!--<div class="input-group" id="wm_btn_luu">-->
<!--<i class="glyphicon glyphicon-floppy-save"></i> Lưu-->
<!--</div>-->
<!--</div>-->
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="input-group" id="wm_btn_them">
<i class="glyphicon glyphicon-plus"></i> Thêm
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="input-group" id="wm_btn_xoa">
<i class="glyphicon glyphicon-remove"></i> Xóa
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
<div class="input-group" id="wm_btn_huy">
<i class="glyphicon glyphicon-trash"></i> Hủy
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<div class="input-group" id="wm_btn_in">
<i class="glyphicon glyphicon-print"></i> In
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<div class="input-group" id="wm_btn_inkemchidinh">
<a href="#" class="input-group-addon button-load"><i class="glyphicon glyphicon-list-alt"></i> In kèm chỉ
định</a>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<div class="input-group" id="wm_btn_ketthuc">
<i class="glyphicon glyphicon-off"></i> Kết thúc
</div>
</div>
CSS:
.row {
margin-bottom: 5px;
margin-top: 10px;
}
#wm_header {
width: 100%;
min-height: 22px;
margin: 0;
/*background-image: linear-gradient(to bottom, #428bca 0px, #2d6ca2 100%);*/
/*background-repeat: repeat-x;*/
background-color: #428bca;
border-color: #2b669a;
color: #ffffff;
font-weight: bold;
padding: 5px;
font-size: 15px;
}
.input-label {
/*background-color: #428bca;*/
background-color: #fff;
border: 0;
font-weight: 700;
min-width: 110px;
text-align: left;
}
.input-group {
margin-bottom: 5px;
margin-top: 10px;
}
.input-group-addon:first-child {
text-decoration: none;
font-weight: bold
}
.button-load {
cursor: default;
background-color: #428bca;
color: #fff;
font-weight: bold;
}
So, my parent DIV contains 3 main DIV which contain a couple DIVs each. I have the parents li elements displayed inline as I want all 3 nested DIVs to be side by side along the width of the parent. I have been successful with getting the first two lined up correctly. The third div has the correct x-axis positioning however on the y-axis it has dropped down and outside of the parent div and I'm not sure where I am going wrong. I have tried many many different solutions on StackOverflow, however, none have had any success.
I have the right-hand div (the one below parent) set to absolute as if it's not then it does not get the correct x-axis, with absolute it gets half the position correct.
Relevant code:
.supContainer {
position: absolute;
top: 900px;
left: 38%;
width: 400px;
}
.supContainer ul {
list-style-type: none;
padding-left: 0px;
margin: 0;
}
.supContainer li {
display: inline-block;
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
}
#supp {
margin-left: 295px;
}
.leftUpper {
width: 233px;
padding-left: 47px;
}
.leftLower {
width: 233px;
padding-bottom: 10px;
}
.supMid {
float: none;
margin-right: 5px;
width: 201px;
padding-left: 238px;
}
.rightUpper {
width: 266px;
}
.rightLower {
width: 266px;
}
.wrapper .leftSide {
margin-top: 24px;
position: absolute;
width: 233px;
left: 0;
}
.wrapper .rightSide {
float: right;
position: absolute;
width: 273px;
left: 445px;
/*top:88px;*/
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
}
#sysit {
margin-left: 35px;
}
#comms {
margin-left: 15px;
}
#collapseExample {
width: 730px;
}
/* GLOBAL CLASSES FOR COMMON ADJUSTMENTS */
.inLine li {
/* Remember to define a width within parent */
display: inline-block;
white-space: nowrap;
}
.borderMe {
border: 2px solid black;
}
.borderMeGreen {
border: 2px solid green;
}
.borderMeRed {
border: 2px solid red;
}
.paddSingleLine {
padding-top: 15px;
padding-bottom: 15px;
}
<div class="supContainer">
<button class="btn btn-warning" id="supp" type="button" data-toggle="collapse" data-target="#collapseExample">Support</button>
<div class="collapse borderMe" id="collapseExample">
<li>
<ul>
<br/>
<div class="wrapper inLine borderMe">
<div class="leftSide">
<div class="leftUpper inLine">
<li>
<button class="btn btn-warning" type="button">Capital
<br/>Equipment</button>
</li>
<li>
<button class="btn btn-warning" type="button">Finance
<br/>Process</button>
</li>
</div>
<div class="leftLower inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">NDA</button>
</li>
<li>
<button class="btn btn-warning" type="button">QMS
<br/>Update</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">Projects</button>
</li>
</div>
</div>
<div class="supMid">
<li>
<button class="btn btn-warning" id="sysit" type="button">Systems and IT</button>
</li>
<br/>
<li>
<button class="btn btn-warning" id="comms" type="button">Communication
<br/>Relationship/Structure</button>
</li>
<br/>
<li>
<button class="btn btn-warning" type="button">Disaster Recovery Planning</button>
</li>
</div>
<div class="rightSide borderMe">
<div class="rightUpper inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">Admin</button>
</li>
<li>
<button class="btn btn-warning" type="button">Recruitment
<br/>/Contractors</button>
</li>
</div>
<div class="rightLower inLine">
<li>
<button class="btn btn-warning" type="button">Export
<br/>Control</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HR Staff</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HS and E</button>
</li>
</div>
</div>
</div>
</ul>
</li>
</div>
</div>
And a screen-grab of the output of the code:
Sorry for the sloppy code I'm new to this. If you could tell me where I've gone wrong but also why it's gone wrong and why the solution will fix it I'd be grateful as it will aid my learning.
Cheers and thanks in advance.
You are messing it up with position:absolute. Check the solution below.
Just update:
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.wrapper .leftSide {
position: relative;
width: 233px;
float: left;
}
.wrapper .rightSide {
float: left;
position: relative;
width: 273px;
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
padding-top: 10px;
}
.supContainer {
position: absolute;
top: 900px;
left: 38%;
width: 400px;
}
.supContainer ul {
list-style-type: none;
padding-left: 0px;
margin: 0;
}
.supContainer li {
display: inline-block;
white-space: nowrap;
margin-top: 10px;
margin-right: 10px;
}
#supp {
margin-left: 295px;
}
.leftUpper {
width: 233px;
padding-left: 47px;
}
.leftLower {
width: 233px;
padding-bottom: 10px;
}
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.rightUpper {
width: 266px;
}
.rightLower {
width: 266px;
}
.wrapper .leftSide {
position: relative;
width: 233px;
float: left;
}
.wrapper .rightSide {
float: left;
position: relative;
width: 273px;
}
.wrapper {
width: 730px;
height: 155px;
overflow: hidden;
padding-top: 10px;
}
#sysit {
margin-left: 35px;
}
#comms {
margin-left: 15px;
}
#collapseExample {
width: 730px;
}
/* GLOBAL CLASSES FOR COMMON ADJUSTMENTS */
.inLine li {
/* Remember to define a width within parent */
display: inline-block;
white-space: nowrap;
}
.borderMe {
border: 2px solid black;
}
.borderMeGreen {
border: 2px solid green;
}
.borderMeRed {
border: 2px solid red;
}
.paddSingleLine {
padding-top: 15px;
padding-bottom: 15px;
}
<div class="supContainer">
<button class="btn btn-warning" id="supp" type="button" data-toggle="collapse" data-target="#collapseExample">Support</button>
<div class="collapse borderMe" id="collapseExample">
<li>
<ul>
<br/>
<div class="wrapper inLine borderMe">
<div class="leftSide">
<div class="leftUpper inLine">
<li>
<button class="btn btn-warning" type="button">Capital
<br/>Equipment</button>
</li>
<li>
<button class="btn btn-warning" type="button">Finance
<br/>Process</button>
</li>
</div>
<div class="leftLower inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">NDA</button>
</li>
<li>
<button class="btn btn-warning" type="button">QMS
<br/>Update</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">Projects</button>
</li>
</div>
</div>
<div class="supMid">
<li>
<button class="btn btn-warning" id="sysit" type="button">Systems and IT</button>
</li>
<br/>
<li>
<button class="btn btn-warning" id="comms" type="button">Communication
<br/>Relationship/Structure</button>
</li>
<br/>
<li>
<button class="btn btn-warning" type="button">Disaster Recovery Planning</button>
</li>
</div>
<div class="rightSide borderMe">
<div class="rightUpper inLine">
<li>
<button class="btn btn-warning paddSingleLine" type="button">Admin</button>
</li>
<li>
<button class="btn btn-warning" type="button">Recruitment
<br/>/Contractors</button>
</li>
</div>
<div class="rightLower inLine">
<li>
<button class="btn btn-warning" type="button">Export
<br/>Control</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HR Staff</button>
</li>
<li>
<button class="btn btn-warning paddSingleLine" type="button">HS and E</button>
</li>
</div>
</div>
</div>
</ul>
</li>
</div>
</div>
Try this
Jsfiddle
Give .supMid property display: inline-block
.supMid{
float:none;
display: inline-block;
margin-right:5px;
width:201px;
padding-left:238px;
}
Just give vertical-align:top to .rightSide. No need of position to set element
.wrapper .rightSide {
float: right;
width: 250px;
vertical-align: top;
}
Try to change some of their properties. I used float instead of position
.wrapper .leftSide {
margin-top: 24px;
float: left;
width: 233px;
}
.supMid {
float: left;
margin-right: 5px;
width: 201px;
}
.wrapper .rightSide {
float: left;
width: 273px;
}
I've been having a hard time getting the hamburger menu to work onnce the screen size decreases to anything below 1200px. How can I get my list items to show up below my top nav bar?
This is what I have so far:
.mainBackground {
background-image: url('https://res.cloudinary.com/knaguibimages/image/upload/o_65/v1474765365/Background_p3qqpv.jpg');
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
#media screen and (min-width: 1200px) {
.body-wrapper {
padding-left: 80px;
}
}
#media screen and (min-width: 1200px) {
.navbar {
width: 80px;
max-width: 80px;
position: fixed;
top: 0;
left: 0;
height: 100%;
border: 0;
border-radius: 0;
text-align: center;
}
}
.navbar {
z-index: 10000;
background: rgba(30, 30, 31, 0.85);
}
#media screen and (max-width: 1200px) {
.navbar-header {
float: left;
padding: 0 40px;
}
}
.navbar-brand {
padding: 50px 0 50px 25px;
float: left;
height: auto;
}
#media screen and (min-width: 1200px) {
.navbar-brand {
position: relative;
box-shadow: none;
margin: 12px 0;
}
}
ul li a span {
display: inline-block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 17px;
}
.btn.responsive-menu {
display: none;
}
#media screen and (max-width: 1200px) {
.btn.responsive-menu {
margin: 45px 50px 0 0;
display: inline-block;
float: right;
}
}
.btn {
color: #0067b5;
background: none;
border: 2px solid;
-webkit-transition: all 200ms ease-in;
}
.current {
color: white;
}
section {
padding-top: 50px;
padding-left: 50px;
padding-right: 70px;
margin-bottom: 106px;
}
section .box {
padding: 50px;
background-color: rgba(0, 0, 0, 0.75);
}
.section-title {
margin-bottom: 20px;
font-size: 22px;
line-height: 28px;
color: white;
}
#aboutMe-responsive {
display: none;
}
#myPortfolio-responsive {
display: none;
}
#contactMe-responsive {
display: none;
}
#aboutMe {
padding: 0 50px 20px 0;
}
#myPortfolio {
padding: 0 50px 20px 0;
}
#contactMe {
padding: 0 50px 20px 0;
}
#media screen and (max-width: 1200px) {
#aboutMe {
display: none;
}
#myPortfolio {
display: none;
}
#contactMe {
display: none;
}
#aboutMe-responsive {
display: inline;
}
#myPortfolio-responsive {
display: inline;
}
#contactMe-responsive {
display: inline;
}
}
.frame {
position: relative;
border: 4px solid;
border-color: rgba(0, 0, 0, 0.5);
overflow: hidden;
margin: 0 0 15px 0;
}
p {
font-size: 15px;
line-height: 30px;
letter-spacing: 0.3px;
color: white;
}
<!--Navigation- Bar-->
<nav class="navbar navbar-default" role="navigation">
<!--Navbar header-->
<div class="navbar-header">
<!-- Logo -->
<div class="navbar-brand text-center">
<!-- <a href="#"> -->
<i id="home" class="fa fa-home fa-2x"></i>
<!-- </a> -->
</div>
</div>
<!--Hamburger menu-->
<a class="btn responsive-menu" data-toggle="collapse" data-target=".navbar-collapse">
<i id="hamburger-menu" class="fa fa-bars fa-2x"></i>
</a>
<!--Navbar Icon Section Navigation-->
<!-- Add "in" when you want to collapse nav bar -->
<div id="nav-section-selection" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<!--About Me-->
<li>
<a href="#about">
<i id="aboutMe" class="fa fa-user fa-2x current"></i>
<span id="aboutMe-responsive">ABOUT ME</span>
</a>
</li>
<!--Portfolio-->
<li>
<a href="#portfolio">
<i id="myPortfolio" class="fa fa-briefcase fa-2x"></i>
<span id="myPortfolio-responsive">MY WORK</span>
</a>
</li>
<!--Contact-->
<li>
<a href="#contact">
<i id="contactMe" class="fa fa-envelope-o fa-2x"></i>
<span id="contactMe-responsive">CONTACT ME</span>
</a>
</li>
</ul>
</div>
</nav>
<!--Page Content Starts Here-->
<div id="pageContent">
<!-- About Me Section -->
<section id="about" class="about-section">
<div class="box">
<h2 class="section-title">A Little About Myself</h2>
<div class="row">
<div class="col-md-5 col-md-push-7">
<figure class="frame">
<img class="img-responsive about-me-img" src="https://res.cloudinary.com/knaguibimages/image/upload/v1474765942/ProfilePic_bvn1gs.jpg" alt="Karim Naguib Profile Picture">
</figure>
</div>
<div class="col-md-7 col-md-pull-5">
<p>Hello! My name's Karim Naguib, and this page was developed to showcase my coding talent.</p>
<p>I graduated from the University of Waterloo in 2015, with a degree in Management Engineering.</p>
</div>
</div>
</div>
</section>
<!-- Portfolio Section -->
<section id="portfolio" class="portfolio-section">
<div class="box">
<h2 class="section-title">My Work</h2>
</div>
</section>
<!-- Contact Section -->
<section id="contact" class="contact-section">
<div class="box">
<h2 class="section-title">Get In Touch With Me</h2>
</div>
</section>
</div>
</div>
<!-- Footer -->
</body>
</html>
you should try this inside your navbar-header class:
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>