0

请帮忙!!!

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?感谢任何回答的人!

4

1 回答 1

0

如果没有实际图像,很难理解您在此处尝试实现的目标。我在这里转载了你的案例:

http://jsfiddle.net/gVQ8x/1/

我刚刚在这里设置了百分比宽度(这-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 hack。改用条件类:http: //paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/

另一个可能在未来引起问题的重要问题是您的文档中有多个共享相同 id 的元素,即前面提到的body #header #h_r #menu. 如果您希望 javascript DOM 操作正常且可预测地工作,则 id 必须是唯一的。

于 2012-07-05T18:24:30.197 回答