Internet Explorer:相对定位的按钮在绝对定位的框中对齐

发布于 2024-09-13 12:31:13 字数 1490 浏览 8 评论 0原文

在 IE7 中,我的订单示例按钮“#itmSampl”并未与其左侧的“.add-to-cart”按钮垂直对齐,但在 FF3.6 和 Chrome 5 中却如此。我需要它在 IE6-8 中正确对齐。有人看到我错过了什么吗?

<style type="text/css">
#buttonbox { position:relative; width:326px; }

#accounting #box-accounting .image-item .content-account .add-to-cart { clear:both; margin:0 0 10px; }
#accounting #box-accounting .image-item .content-account
#ordrWizrd { float:left; height:24px; width:111px; }
#accounting #box-accounting .image-item .content-account .add-to-cart { clear:both; margin:0 0 10px; }
#itmSampl { bottom:0; cursor:pointer; display:block; height:24px; margin:0 3px 2px; position:absolute; right:0; width:120px; } .clearfix { clear:both; height:0; } </style>

<div id="buttonbox">
    <div id="addtocart2" class="add-to-cart">
    <table><%=getCurrentAttribute('item','addtocarthtml')%></table>
    </div>
    <div id="ordrWizrd" class="add-to-cart"><a href="javascript:shwWizd()"><img src="/images/img/add-to-cart.gif" alt="configure item"></a></div>     
    <div id="itmSampl"></div>
    </div>  <div class="clearfix"></div> </div>

另外,如果视觉效果有帮助的话,这里是测试页面(您必须登录才能看到按钮而不是项目符号列表): http://www.avaline.com/85W_test_2 登录:[电子邮件受保护] 通过:test03

In IE7, my order sample button "#itmSampl" isn't vertically aligned with the ".add-to-cart" button to the left of it, although in FF3.6 and Chrome 5 it is. I need it to be aligned correctly in IE6-8. Does anyone see what I'm missing?

<style type="text/css">
#buttonbox { position:relative; width:326px; }

#accounting #box-accounting .image-item .content-account .add-to-cart { clear:both; margin:0 0 10px; }
#accounting #box-accounting .image-item .content-account
#ordrWizrd { float:left; height:24px; width:111px; }
#accounting #box-accounting .image-item .content-account .add-to-cart { clear:both; margin:0 0 10px; }
#itmSampl { bottom:0; cursor:pointer; display:block; height:24px; margin:0 3px 2px; position:absolute; right:0; width:120px; } .clearfix { clear:both; height:0; } </style>

<div id="buttonbox">
    <div id="addtocart2" class="add-to-cart">
    <table><%=getCurrentAttribute('item','addtocarthtml')%></table>
    </div>
    <div id="ordrWizrd" class="add-to-cart"><a href="javascript:shwWizd()"><img src="/images/img/add-to-cart.gif" alt="configure item"></a></div>     
    <div id="itmSampl"></div>
    </div>  <div class="clearfix"></div> </div>

Also, here's the test page if a visual helps (you have to login to see the buttons instead of the bulleted list): http://www.avaline.com/85W_test_2
Login:[email protected]
Pass:test03

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

聊慰 2024-09-20 12:31:13

解决方案 1:由于您已经在页面中使用了很多表格,因此另一个表格不会有什么坏处 - 只需将您的 HTML 从上面的内容更改为类似这样的内容(可能需要一些调整) :

<div id="buttonbox">
    <div id="addtocart2" class="add-to-cart">
        <table><tr>
            <td><table><%=getCurrentAttribute('item','addtocarthtml')%></table></td>
            <td valign="bottom"><div id="itmSampl"></div></td>
        </tr></table>
    </div>
    <div class="clearfix"></div>
</div>
<!-- And also put #ordrWizrd in there somewhere -->

解决方案 2:使用 #itmSample 删除所有“position:absolute”内容(删除 CSS 底部、位置、右侧,也许还有边距和高度/宽度属性)。然后,添加 CSS float: right; margin-top: -36px; 到#itmSample,使其向右浮动并向上移动 36 像素。

Solution 1: Since you are already using a lot of tables in your page, another one won't hurt - just change your HTML from what you have above to something like this (may require a few tweaks):

<div id="buttonbox">
    <div id="addtocart2" class="add-to-cart">
        <table><tr>
            <td><table><%=getCurrentAttribute('item','addtocarthtml')%></table></td>
            <td valign="bottom"><div id="itmSampl"></div></td>
        </tr></table>
    </div>
    <div class="clearfix"></div>
</div>
<!-- And also put #ordrWizrd in there somewhere -->

Solution 2: Take away all the "position: absolute" stuff with #itmSampl (remove the CSS bottom, position, right, and maybe margin and height/width properties). Then, add CSS float: right; margin-top: -36px; to #itmSampl to make it float on the right and move upward 36 pixels.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文