答案 0 :(得分:1)
您有两种选择。您可以通过在CSS中将width: 1000px
的两个实例替换为width: 100%
来使整个导航栏响应(就像这样)(您需要单独设置导航链接的样式,然后使用@media-queries
屏幕较小的设备):
#navs{
position: relative;
width:100%;
left:0;
right:0;
top:0;
-webkit-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.25);
-moz-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.25);
box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.25);
z-index:10000;
}
#navs > .top-nav{
position:relative;
background:#555;
height:20px;
border-bottom:1px solid #333;
}
#navs > .top-nav > .top-nav-content{
width:100%;
margin:0 auto;
color:#ddd;
font-size:12px;
text-align: right;
}
#navs > .middle-nav{
position:relative;
background:#0b99d0 url('../img/middle-nav-bg.png');
background-repeat:repeat-x;
height:50px; width:100%;
background-repeat:repeat-x;
min-width: 1100;
}
#navs > .middle-nav > .logo-container{
width:100%;
margin:0 auto;
height:50px;
}
.logo, .usr-login{
display:inline-block;
}
#navs > .middle-nav > .logo-container > .logo{
background:url('../img/logo.png');
background-repeat:no-repeat;
background-size:contain;
background-position: right bottom;
text-shadow:1px 1px #023f52;
text-transform: uppercase;
width:215px;height:50px;
font-size:28px;
font-weight:bold;
color:#eee;
}
.body-holder{
width:1120px;
margin:0 auto;
}
.usr-login{
float:right;
margin-top:0px;
color:#eee;
margin-right:10%;
margin-top:13px;
}
#navs > .last-nav{
width:100%;
background:#fff;
background-repeat:repeat-x;
background-size:contain;
padding-top:4px;
}
#navs > .last-nav > .last-nav-content{
width:100%;
margin:0 auto;
height:44px;
}
.nav-menu-wrap, .search-menu-wrap{
height:40px;
display: inline-block;
}
.nav-menu-wrap {
width:29%;height:40px;
position:relative;
}
.search-menu-wrap{
width:70%;height:40px;
position: relative;
top:3px;
}
.nav-menu-wrap > ul {
list-style-type: none;
overflow: hidden;
position: relative;
top:-3px;
float:right;
}
.nav-menu-wrap > ul li {
float: left;
border-left:1px solid #e9e9e9;
border-right:1px solid #fff;
padding:12px 4px;
}
.nav-menu-wrap > ul li:first-child {
border-left:1px solid #e9e9e9;
}
.nav-menu-wrap > ul li:last-child {
border-right:1px solid #e9e9e9;
}
.nav-menu-wrap > ul li a {
display: block;
width: 60px;
background-color: #fff;
text-align:center;
color:#0694c6;
outline:none;
}
.nav-menu-wrap > ul li a:hover {
text-decoration:none;
}
.nav-login ul {
margin: 0;
padding: 0;
list-style: none;
position: relative;
float: right;
font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif;
}
.nav-login li {
float: left;
}
.nav-login #login {
border-right:0;
}
.nav-login #login-trigger,
.nav-login #signup a {
display: inline-block;
*display: inline;
padding: 0 8px;
text-decoration: none;
color: #ddd;
font-weight:600;
font-size:14px;
}
.drp-icon{
font-size:10px;
}
.kp-me-lin{
font-weight:100;
}
.nav-login #signup a {
border-radius: 0 3px 3px 0;
}
.nav-login #login-trigger {
border-radius: 3px 0 0 3px;
outline: 0;
outline-style:none;
outline-width:0;
}
.nav-login #login-trigger:hover,
.nav-login #login .active,
.nav-login #signup a:hover {
color:#ddd;
text-shadow:1px 1px #004b63;
outline: 0;
outline-style:none;
outline-width:0;
}
.nav-login #login-content {
display: none;
position: absolute;
top: 24px;
right: 0;
z-index: 999;
background: #fff;
background-image: linear-gradient(top, #fff, #eee);
padding: 15px;
border:1px solid #efefef;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.14);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.14);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.14);
color:#444;
border-radius:4px;
}
.nav-login li #login-content {
right: 0;
width: 270px;
}
#inputs input {
background: #f1f1f1;
padding: 6px 5px;
margin: 0 0 5px 0;
width: 238px;
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: 0 1px 1px #ccc inset;
}

<body style="background:#efefef;">
<div id="navs">
<div class="top-nav">
<div class="top-nav-content">Number</div> </div>
<div class="middle-nav">
<div class="logo-container"><div class="logo">Head</div><div class="usr-login">
<div class="nav-login">
<ul>
<li id="login">
<a id="login-trigger" href="#">
Login <b class="drp-icon">▼</b>
</a>
<div id="login-content">
<form>
<fieldset id="inputs">
<input id="usercath" type="email" cath="Email" placeholder="Your email address" required>
<input id="password" type="password" cath="Password" placeholder="Password" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Log in">
<label class="kp-me-lin"><input type="checkbox" checked="checked"> Keep me signed in</label>
</fieldset>
</form>
</div>
</li>
<li id="signup">
<a href="">Register</a>
</li>
</ul>
</div></div>
</div></div>
<div class="last-nav"><div class="last-nav-content">
<div class="search-menu-wrap">
<div class="input-group">
<div class="input-group-btn">
<div class="preview">
</select>
</div>
</div>
<!-- /btn-group -->
</div>
</div>
<div class="nav-menu-wrap">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="#news">Deals</a></li>
<li><a href="#contact">Account</a></li>
<li><a href="#about">Help</a></li>
</ul>
</div>
</div></div>
</div>
</div>
<div class="body-holder">
&#13;
或者您可以使整个导航栏保持静态,即无论您在哪个屏幕上查看屏幕尺寸,它的宽度都会固定,如下所示:
#navs{
position: relative;
width:1200px;
left:0;
right:0;
top:0;
-webkit-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.25);
-moz-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.25);
box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.25);
z-index:10000;
}
#navs > .top-nav{
position:relative;
background:#555;
height:20px;
border-bottom:1px solid #333;
}
#navs > .top-nav > .top-nav-content{
width:1200px;
margin:0 auto;
color:#ddd;
font-size:12px;
text-align: right;
}
#navs > .middle-nav{
position:relative;
background:#0b99d0 url('../img/middle-nav-bg.png');
background-repeat:repeat-x;
height:50px; width:1200px;
background-repeat:repeat-x;
min-width: 1100;
}
#navs > .middle-nav > .logo-container{
width:1200px;
margin:0 auto;
height:50px;
}
.logo, .usr-login{
display:inline-block;
}
#navs > .middle-nav > .logo-container > .logo{
background:url('../img/logo.png');
background-repeat:no-repeat;
background-size:contain;
background-position: right bottom;
text-shadow:1px 1px #023f52;
text-transform: uppercase;
width:215px;height:50px;
font-size:28px;
font-weight:bold;
color:#eee;
}
.body-holder{
width:1120px;
margin:0 auto;
}
.usr-login{
float:right;
margin-top:0px;
color:#eee;
margin-right:10%;
margin-top:13px;
}
#navs > .last-nav{
width:1200px;
background:#fff;
background-repeat:repeat-x;
background-size:contain;
padding-top:4px;
}
#navs > .last-nav > .last-nav-content{
width:1200px;
margin:0 auto;
height:44px;
}
.nav-menu-wrap, .search-menu-wrap{
height:40px;
display: inline-block;
}
.nav-menu-wrap {
width:29%;height:40px;
position:relative;
}
.search-menu-wrap{
width:70%;height:40px;
position: relative;
top:3px;
}
.nav-menu-wrap > ul {
list-style-type: none;
overflow: hidden;
position: relative;
top:-3px;
float:right;
}
.nav-menu-wrap > ul li {
float: left;
border-left:1px solid #e9e9e9;
border-right:1px solid #fff;
padding:12px 4px;
}
.nav-menu-wrap > ul li:first-child {
border-left:1px solid #e9e9e9;
}
.nav-menu-wrap > ul li:last-child {
border-right:1px solid #e9e9e9;
}
.nav-menu-wrap > ul li a {
display: block;
width: 60px;
background-color: #fff;
text-align:center;
color:#0694c6;
outline:none;
}
.nav-menu-wrap > ul li a:hover {
text-decoration:none;
}
.nav-login ul {
margin: 0;
padding: 0;
list-style: none;
position: relative;
float: right;
font-family: Optima, Segoe, "Segoe UI", Candara, Calibri, Arial, sans-serif;
}
.nav-login li {
float: left;
}
.nav-login #login {
border-right:0;
}
.nav-login #login-trigger,
.nav-login #signup a {
display: inline-block;
*display: inline;
padding: 0 8px;
text-decoration: none;
color: #ddd;
font-weight:600;
font-size:14px;
}
.drp-icon{
font-size:10px;
}
.kp-me-lin{
font-weight:100;
}
.nav-login #signup a {
border-radius: 0 3px 3px 0;
}
.nav-login #login-trigger {
border-radius: 3px 0 0 3px;
outline: 0;
outline-style:none;
outline-width:0;
}
.nav-login #login-trigger:hover,
.nav-login #login .active,
.nav-login #signup a:hover {
color:#ddd;
text-shadow:1px 1px #004b63;
outline: 0;
outline-style:none;
outline-width:0;
}
.nav-login #login-content {
display: none;
position: absolute;
top: 24px;
right: 0;
z-index: 999;
background: #fff;
background-image: linear-gradient(top, #fff, #eee);
padding: 15px;
border:1px solid #efefef;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.14);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.14);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.14);
color:#444;
border-radius:4px;
}
.nav-login li #login-content {
right: 0;
width: 270px;
}
#inputs input {
background: #f1f1f1;
padding: 6px 5px;
margin: 0 0 5px 0;
width: 238px;
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: 0 1px 1px #ccc inset;
}
&#13;
<body style="background:#efefef;">
<div id="navs">
<div class="top-nav">
<div class="top-nav-content">Number</div> </div>
<div class="middle-nav">
<div class="logo-container"><div class="logo">Head</div><div class="usr-login">
<div class="nav-login">
<ul>
<li id="login">
<a id="login-trigger" href="#">
Login <b class="drp-icon">▼</b>
</a>
<div id="login-content">
<form>
<fieldset id="inputs">
<input id="usercath" type="email" cath="Email" placeholder="Your email address" required>
<input id="password" type="password" cath="Password" placeholder="Password" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Log in">
<label class="kp-me-lin"><input type="checkbox" checked="checked"> Keep me signed in</label>
</fieldset>
</form>
</div>
</li>
<li id="signup">
<a href="">Register</a>
</li>
</ul>
</div></div>
</div></div>
<div class="last-nav"><div class="last-nav-content">
<div class="search-menu-wrap">
<div class="input-group">
<div class="input-group-btn">
<div class="preview">
</select>
</div>
</div>
<!-- /btn-group -->
</div>
</div>
<div class="nav-menu-wrap">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="#news">Deals</a></li>
<li><a href="#contact">Account</a></li>
<li><a href="#about">Help</a></li>
</ul>
</div>
</div></div>
</div>
</div>
<div class="body-holder">
&#13;