I am designing a header and have a few questions about the issues I have.
The demo is here and the code is below, any help would be much appreciated.
.menu {
position: relative;
width: 100%;
height: 66px;
max-height: 90px;
background: green;
}
.menu img {
max-height: 30px;
}
.menu ul {
left: 0;
margin: 0 auto;
width: 80%;
margin: -30px auto 0 auto;
font-size: 16px;
font-weight: bold;
max-width: 1200px;
}
.menu ul li:first-child {
border-left: 1px solid gray;
}
.menu ul li {
//
width: 140px;
width: 14%;
display: block;
float: left;
text-align: center;
border-right: 1px solid gray;
color: white;
height: 50px;
line-height: 70px;
vertical-align: bottom;
}
.menu ul li a {
color: white;
}
.menubtn {
width: 30px;
height: 30px; //
opacity: 0.5;
cursor: pointer;
}
.menubtn .fa {
font-size: 26px;
color: rgb(75, 0, 130)
}
#menubtn {
position: absolute;
top: 2px;
left: 4px;
}
@media only screen and (min-width: 501px) {
.topbar {
display: none;
}
.menu ul li a {
font-size: 14px;
}
#mybody {
margin-top: 8%;
}
}
@media only screen and (max-width: 1200px) {
.menu ul li a {
font-size: 12px;
}
}
@media only screen and (max-width: 888px) {
.menu ul li a {
font-size: 12px;
}
}
@media only screen and (max-width: 685px) {
.menu {
height: 40px;
}
.menu ul {
margin: 0;
}
.menu img {
display: none
}
.menu ul {
width: 100%;
}
.menu ul li {
line-height: 40px;
height: 40px;
font-size: 13px;
}
}
@media (max-height: 480px) and (min-width: 480px) and (max-width: 600px) {
.menu {
display: none;
}
}
@media only screen and (min-width: 320px) and (max-width: 480px) and (orientation: landscape) {
.menu {
display: none;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/4.2.1/bootstrap-social.css">
</head>
<body>
<header>
<div class="container-fluid">
<div class="row" style="background-color: lightblue;">
<div class="col-md-8 col-sm-8 col-xs-1">
<div id="banner" style="margin-left: 59%;">
<img height="25px" width="25px" src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRROdI3yg-dOO1Wl56Ci6AHheWnzUA6j01oJDvxaUNViODWLpLX" />
<img height="40px;" width="253px;" src="http://staticx.ibncollege.com/wcsstore/ExtendedSitesCatalogAssetStore/907_90722_1_21939/images/FULLIMAGE_88753.jpg" />
</div>
</div>
<div class="col-md-2">
<div id="images" style="float: right;">
<a class="btn btn-social-icon btn-sm btn-facebook" style="text-align: center;" href="#"> <i class="fa fa-facebook"></i>
</a>
<a class="btn btn-social-icon btn-sm btn-twitter" href="#"> <i class="fa fa-twitter"></i>
</a>
<a class="btn btn-social-icon btn-sm btn-google-plus" href="#">
<i class="fa fa-google-plus"></i>
</a>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12 search-container">
<form id="searchbox" role="form" action="#" method="GET">
<div class="col-md-4 col-sm-12 col-xs-12 searchbox">
<div class="ui-widget">
<input id="Name" name="name" class="form-control searchinput" type="text" placeholder="name" value="">
</div>
</div>
<div class="col-md-4 col-sm-12 col-xs-12">
<input id="family" name="family" class="form-control searchinput" type="text" placeholder="family" value="">
</div>
<div class="col-md-2 col-sm-2 col-xs-1">
<button style="background-color: blue; border-radius: 14px; border-style: solid;" class="btn-search" type="submit" title="Search">
<div style="background-color: blue;">
<span class="glyphicon glyphicon-search"></span>
</div>
</button>
</div>
</form>
<div style="float: right; text-align: right;" class="col-md">
<a href="#">Click1</a> <a href="#">Click2</a>
</div>
</div>
</div>
</div>
<div class="hidden-xs">
<div class="menu">
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTnYmtXUnZ6g5TwfPndnVQMcVdJO8qkSJqm-dPkNRJ_13IaeTP6Pw" style="width: 100%; max-height: 40px;">
<ul id="idmenu">
<li><a href="#">Item1</a>
</li>
<li><a href="#">Item2</a>
</li>
<li><a href="#">Item3</a>
</li>
<li><a href="#">Item4</a>
</li>
<li><a href="#">Item5</a>
</li>
<li><a href="#">Item6</a>
</li>
<li><a href="#">Item7</a>
</li>
<li><a href="#">Item8</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</header>
</body>
</html>
The way I want it to be is as following:
As you can see I have a logo at the right side of the search box, that is from top of the page to the bottom of the search box.
A banner in middle, three social media links and two links that are positioned in slightly right bottom side of the social media links.
I also have a white image on top of the menu that will be replaced with a proper image.
(I am not creating the menu using nav
because of that image that should be on top of the menu;therefore, I have problem with mobile size screen as well, need to do that manually therefore, help to design that with nav would also be appreciated)
I was asked to narrow down the requirement,
-
I need to put the logo in the location that is shown in the screen shot, not where it is, (it is now at the left side of the banner – please click on ‘demo is here’ link to see).
-
Also need to create a hamburger style menu for mobile screens, as I am not using nav it is difficult to achieve. If you know how to solve the issue with nav I would appreciate it, as you can see the current menu is not based on nav.
I need it to be responsive, so if you make any changes I would be grateful if you could consider that.
2
Answers
To start with, for a hamburger style menu on mobile devices I highly recommend FlexNav.
Now, most of what you are trying to do can be accomplished by adding some extra divs, I will explain:
The whole idea of a responsive design is that items are stacked on top of each other, and when you get to a certain point (breakpoint) they float up to sit beside other elements.
The above example shows what would happen if all containers were made
float: left;
at the widescreen breakpoint.All of the elements that you want to float next to other elements need be inside the same container. In your case that means one container should have your logo in it, the next container should have your banner, input fields and search box, and the last container should have your social links. Or if you want the social links near the top on mobile you could use
float: right;
instead offloat: left;
and put them in an earlier container.To have your form elements next to each other, they will need
width
of 50% or less. Percentages work very well for responsive theming.Finally, if you’re planning to do a lot of responsive theming there are tools out there than can be a bit challenging to set up and learn, but make the whole process MUCH smoother such as:
Well, as I always said it’s faster, easier and, specially cleaner, to NOT use boostrap when you want to translate your design to web. Bootstrap is a tool to make fast responsive webs under Twitter own design. It’s good but NOT miraculous. IF you want your own designs on webs you NEED to know css, whatever to modified bootstrap or do it from scratch (and if you know css then you woudn’t use bootstrap too much).
I will start from scratch.
It’s easier when you start with your html layout without, yet, adding the main elements:
And then you add css’s to position the layout correctly (and better if you use colors to make it easier to check everything is ok):
As you can see in this FIDDLE in progress, everything makes sense, and is responsive just adding a single line of
media queries
.The social panel won’t change it’s width so at 600px (you may set your desire break width) width, I have changed themenú-top-center
to get all the parent width but the social container. Notice, please I also made de main container to be of a máximum width of 970px (as in your example)Also, I have set some heights just to be able to check the layout, later on I will delete many properties as the content will set the right height.
Now it’s time to put the elements inside their html containers.
Icons to the left of your login adding the images at the html and as css. Right atm they are on a container responsive so the images inside will change their width as you resize window. If you want a fixed size then give to the container a width on
px
and to thecontainer-login
a width with, againwidth:calc(100% - yourwidthpx);
:Your “logo” image in the html with your desired size (removing now the height of his parent):
Your login
inputs
inside login div (removing now the height of his parent) and the mediaquery to make it resposnive:Your social icons (I recomend you to insert them as a list in the html):
Your Links:
Then remove heights and background-colors and that’s it: FIDDLE
Of course there are still stuff to do to style your project, after all this is the layout, I will leave some work for You 🙂
If I have time later tonight I may complete your menu trying to explain how to make it resposive with a “burger” icon.
Trust me, All this is MUCH easier and faster tan overriding and modifying your bootstrap to make it look as you want.
Edited (“burger” menú):
Now let’s make the main menú (base on your image). The html is easy:
Where
burger
is the icon. We giveposition:absolute
to this container and we hide it usingdisplay:none
. Then with mediaqueries we show the icon while hidden our list. We also need to change theli’s
fromdisplay:inline-block
todisplay:block
and finally set a min-height to the main container so while the list is hidden you still have the “green” menú nav:We also add our last class:
visible
will just change the display of your list once you click on the burger icon. For that you just need a very simple jquery code:This could be made with just css and using hover insteed of click, but I find it much better the click event and you future users probably will have a better experience
And that’s it. Quite simple, easy to understand and just a few lines of css.
Final FIDDLE. Good luck with your project