Reputation: 177
I'm having a problem getting the result by having the logo centered and then the nav right aligned and centered vertically within the header and then as it scales down to a responsive mode it will stack on top of one another. I can get the desired effect on the desktop mode by making the nav position: absolute; but then it screws up my responsive queries.
Anyone have an idea?
Here is the fiddle: http://jsfiddle.net/W37Wq/1/
HTML
<div class="header">
<div class="header-inner">
<a href="www.google.com"><img class="logo" src="http://www.techcityng.com/wp-content/uploads/2013/07/google.jpg"></a>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Let's Partner</a>
<a href="#">Contact</a>
</nav>
</div>
</div>
<header class="clearfix">
CSS
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #f6f6f6;
z-index: 10000;
height: 100px;
overflow: hidden;
}
.header .header-inner {
width: 90%;
max-width: 69em;
margin: 0 auto;
padding: 0 1.875em;
text-align: center;
}
.header h1,
.header nav a {
line-height: 100px;
}
.header h1 {
text-transform: uppercase;
color: #333;
letter-spacing: 4px;
font-size: 1em;
display: block;
block;
margin: 0 auto;
text-align: center;
float: none;
overflow: hidden;
}
.header nav {
display: inline-block;
text-align: right;
list-style: none;
margin-left: 5em;
position: absolute;
}
.header nav a {
color: #aaa;
font-weight: 700;
margin: 0 0 0 20px;
font-size: .9em;
}
.header nav a:hover {
color: #333;
}
.logo {
display: inline-block;
max-width: 198px;
max-height: 100px;
}
@media screen and (max-width: 55em) {
.header .header-inner {
width: 100%;
}
.header .logo,
.header nav {
display: block;
margin: 0 auto;
text-align: center;
float: none;
}
.header .logo,
.header nav a {
line-height: 50px;
}
.header nav a {
margin: 0 10px;
}
.header .logo,
.header.header-shrink nav a {
line-height: 45px;
}
.header .logo {
font-size: 2em;
max-height: 60px;
}
.header.header-shrink nav a {
font-size: 1em;
}
}
@media screen and (max-width: 32.25em) {
.header nav a {
font-size: .9em;
}
}
@media screen and (max-width: 24em) {
.header nav a,
.header.header-shrink nav a {
line-height: 1;
}
}
Thank you!
Upvotes: 2
Views: 987
Reputation: 154
Chenge this class:
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #f6f6f6;
z-index: 10000;
height: 110px;
overflow: hidden;
}
.header .header-inner {
width: 90%;
margin: 0 auto;
padding: 0% 5%;
text-align: center;
}
@media screen and (max-width: 55em) {
.header .header-inner {
}
.header .logo,
.header nav {
display: block;
margin: 0 auto;
text-align: center;
float: none;
width:90%;
}
}
Upvotes: 1
Reputation: 3978
Just add position:relative;
in your media query call:
@media screen and (max-width: 55em) {
.header .logo,
.header nav {
display: block;
margin: 0 auto;
text-align: center;
float: none;
position:relative;
}
}
Upvotes: 0