简体   繁体   English

IE7 - 在新线上浮动元素

[英]IE7 - floated elements on new line

(Apologies as this is probably the gazillionth version of this bug, but I've googled for various flavours of this problem, and tried various versions of the suggested fixes, but so far I haven't got a working fix.) (抱歉,因为这可能是这个bug的第几个版本,但我已经搜索了这个问题的各种版本,并尝试了各种版本的建议修复,但到目前为止我还没有一个有效的修复。)

I'm trying to float 2 buttons to the right-hand end of a header bar. 我试图将2个按钮浮动到标题栏的右端。 They have to float as one or both or neither may be displayed (they're buttons to redisplay hidden elements on the page) 它们必须作为一个或两个浮动,或者两者都不显示(它们是重新显示页面上隐藏元素的按钮)

Here's an image comparing the desired layout with the IE7 version. 这是一个将所需布局与IE7版本进行比较的图像。

Small JPG Image on Skydrive Skydrive上的小JPG图像

As you can see, both buttons (and also a filler div that just contains a space) are below the header bar rather than inside it. 如您所见,两个按钮(以及仅包含空格的填充div)位于标题栏下方而不是内部。

Here's the page... 这是页面......

             <div class="divHeaderBar">
                Welcome To James Hay Online
                <div id="filler" style="display: inline-block; *display: inline; float: right; width: 20px; height: 10px; z-index: 60;"> </div>
                <div id="divShowApplyOnline" class="" style="display: inline-block; *display: inline; float: right; margin-top: 5px; height: 10px; width: 20px; z-index: 60; cursor: pointer;"
                    onclick="javascript:ShowApplyOnline()" runat="server">
                    <img title="Show the Apply Online section" src="/portal/images/details_open.png"
                    alt="Show the Apply Online section" />
                </div>
                <div id="divShowMainFeature" class="" style="display: inline-block; *display: inline; float: right; margin-top: 5px; height: 10px; width: 20px; z-index: 60; cursor: pointer;"
                    onclick="javascript:ShowMainFeature()" runat="server">
                    <img title="Show the News Feature section" src="/portal/images/details_open.png"
                    alt="Show the News Feature section" />
                </div>
            </div>

And here's the one bit of styling that's in a stylesheet... 这是样式表中的一点造型......

.divHeaderBar {
   background-color:       #008DA9;
   color:                  White;
   font-weight:            bold;
   font-size:              10pt;
   line-height:            30px;
   text-indent:            10px;
}

I've tried fiddling around with position: absolute and right: 0, and I've tried using a containing div with float: left but so far nothing I've tried has done the trick. 我已经尝试摆弄位置:绝对和右:0,我已经尝试使用包含浮点数的div:left但是到目前为止我没有试过没有做过这个伎俩。

Any help would be much appreciated! 任何帮助将非常感激!

Switching the markup position should help: 切换标记位置应该有助于:

     <div class="divHeaderBar">
        <div id="filler" style="display: inline-block; *display: inline; float: right; width: 20px; height: 10px; z-index: 60;"> </div>
        <div id="divShowApplyOnline" class="" style="display: inline-block; *display: inline; float: right; margin-top: 5px; height: 10px; width: 20px; z-index: 60; cursor: pointer;"
            onclick="javascript:ShowApplyOnline()" runat="server">
            <img title="Show the Apply Online section" src="/portal/images/details_open.png"
            alt="Show the Apply Online section" />
        </div>
        <div id="divShowMainFeature" class="" style="display: inline-block; *display: inline; float: right; margin-top: 5px; height: 10px; width: 20px; z-index: 60; cursor: pointer;"
            onclick="javascript:ShowMainFeature()" runat="server">
            <img title="Show the News Feature section" src="/portal/images/details_open.png"
            alt="Show the News Feature section" />
        </div>
        Welcome To James Hay Online
    </div>

The right floated elements come first - then everything else. 首先是正确的浮动元素 - 然后是其他所有元素。 This way, IE7 should float them correctly. 这样,IE7应该正确浮动它们。

Tip: : consider separating your HTML, CSS and Javascript. 提示::考虑分离HTML,CSS和Javascript。 Inline CSS and inline event handlers are not a very good idea. 内联CSS和内联事件处理程序不是一个好主意。 Separation of concerns will improve readability and maintainabilty. 关注点的分离将提高可读性和可维护性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM