请帮助!!!
CSS:
body
{
margin: 0px;
padding: 0px;
}
body #header {
width:100%;
clear:both;
height:90px;
/*overflow:hidden*/;
box-shadow: 1px 0px 10px 2px #000;
}
body #header #h_l {
width: 30%;
height: 90px;
background-image: linear-gradient(top, #e1e1e1 40%, #9d9d9d 99%);
background-image: -o-linear-gradient(top, #e1e1e1 40%, #9d9d9d 99%);
background-image: -moz-linear-gradient(top, #e1e1e1 40%, #9d9d9d 99%);
background-image: -webkit-linear-gradient(top, #e1e1e1 40%, #9d9d9d 99%);
background-image: -ms-linear-gradient(top, #e1e1e1 40%, #9d9d9d 99%);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(40%, #e1e1e1), color-stop(99%, #9d9d9d)); /* Safari 4+, Chrome 2+ */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e1e1e1', endColorstr='#9d9d9d'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#e1e1e1', endColorstr='#9d9d9d')"; /* IE8+ */
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.40, #e1e1e1),
color-stop(0.99, #9d9d9d)
);
float:left;
}
body #header #h_l #logo {
float: right;
/*-ms-interpolation-mode:bicubic; */
max-width: 100%;
width: auto\9; /* ie8 */
}
body #header #h_r {
width: 70%;
height: 90px;
background: #747474;
float: right;
}
body #header #h_r #menu {
position: relative;
left: -50px;
float:left;
/*-ms-interpolation-mode:bicubic; */
max-width: 100%;
width: auto\9; /* ie8 */
}
HTML:
<body >
<div id="header">
<div id="h_l">
<img id="logo" title="logo" alt="logo" src="{HTTP}{WEBSITE}/images/newlook/MM/logo_plus100px_right.png" >
</div>
<div id="h_r">
<span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Home_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Solutions_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Support_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Company_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Contact_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Blog_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Reseller_but.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Divider_1.png" ></span><span ><img id="menu" title="" alt="" src="{HTTP}{WEBSITE}/images/newlook/MM/Apps_but.png" ></span>
</div>
</div>
</body>
为什么右边菜单中的元素会在浏览器窗口大小调整上逐个继续新行?我怎样才能让它停止这样做,并使其能够像浏览器窗口大小调整一样调整左侧图像的大小(就好像整个菜单将是一个完整的块)?它可以在CSS中完成还是我需要制作一个JavaScript?感谢任何回答的人!
答案 0 :(得分:0)
在没有实际图像的情况下,要理解你想要实现的目标并不容易。我在这里复制了你的案子:
我刚刚在这里设置百分比宽度(-ms-interpolation-mode
部分是什么?):
body #header #h_r #menu {
position: relative;
left: -50px;
float:left;
/*-ms-interpolation-mode:bicubic; */
max-width: 100%;
width: 6%; /* was auto\9 */
}
我强烈建议您不要使用IE黑客攻击。请尝试使用条件类:http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
将来可能导致问题的另一个重要问题是,您的文档中有多个共享相同ID的元素,即前面提到的body #header #h_r #menu
。如果您希望javascript DOM操作正常且可预测地工作,则id必须是唯一的。