简体   繁体   English

保证金:自动在 IE7 中不起作用

[英]margin:auto not working in IE7

I have a paging control on my site that has it's container element set to margin:auto so that the pager control are centered within the element.我的站点上有一个分页控件,它的容器元素设置为 margin:auto,以便分页控件在元素内居中。 It works great on all browsers except for IE7.它适用于除 IE7 以外的所有浏览器。 In fact, I just realized my site has several issues with IE7 and I'm trying to work through them all.事实上,我刚刚意识到我的网站在 IE7 方面存在一些问题,我正在努力解决所有这些问题。 However, I've been stuck on this one for some time.但是,我已经坚持了一段时间。

Take a look at this page .看看这个页面

(I know there are other IE7 issues on this page, focusing on the pager controls first). (我知道此页面上还有其他 IE7 问题,首先关注分页器控件)。 If you use IE9, you can hit F12 and set the "Browser Mode" to IE7 in the menu bar.如果您使用 IE9,您可以按F12并在菜单栏中将“浏览器模式”设置为 IE7。 Compare it to the same page in any other browser/version.将其与任何其他浏览器/版本中的同一页面进行比较。

Can anyone tell me specifically why this is happening based on the CSS/HTML I'm using?谁能根据我正在使用的 CSS/HTML 具体告诉我为什么会发生这种情况? I've been trying things for what seems like hours and I'm not really getting anywhere with it.我已经尝试了好几个小时,但我并没有真正取得任何进展。

The problem is that you're relying on display: table to shrink-wrap the ul to the width of the li s inside it.问题是您依靠display: tableul收缩包装到其中li的宽度。 Unfortunately, display: table is not supported in IE7.不幸的是, IE7 不支持display: table

Switching to display: inline-block is one way to fix this.切换到display: inline-block是解决这个问题的一种方法。

On previous_next_container_forum ul.list_paging , remove display: table and add :previous_next_container_forum ul.list_paging ,删除display: table 并添加

display: inline-block;
*display: inline;
zoom: 1;

The ul is now exactly as wide as the li s inside it, without the use of display: table .使用display: table的情况下, ul现在与其中的li一样宽。

To actually make it centered, you need to add text-align: center to a parent element, such as .previous_next_container_forum .要使其真正居中,您需要将text-align: center添加到父元素,例如.previous_next_container_forum

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

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