English 中文(简体)
Center Horizontally and Vertically of page IE 6+
原标题:Center Horizontally and Vertically of page IE 6+

I m 试图将1#div方框放在2个小型#divs 在其内部,在屏幕/网页的准确中间,最好是贯穿所有决议和IE 6 +,什么是最佳办法?

margin:0 auto; 

似乎从横向来看,但从纵向来看究竟是什么?

最佳回答

如果你知道你想要集中的那部分内容的规模,你可以确定以下中心:

#centered {
    position   : absolute;
    left       : 50%;
    top        : 50%;
    width      : 150px;
    height     : 200px;
    margin     : -100px 0 0 -75px;/*set the left and top margins to the negative of half the element s width and height (respectively)*/
    background : #000;
}

请注意,该要素的母体须有<编码>>>>>>>>>> 代号(>,除<代码>外的代号>:

#container {
    position : relative;
    width    : 100%;
    height   : 100%;
    border   : 1px solid #000;
}

http://jsfiddle。

P.S. I checked and this works in I.E. 6.

问题回答

我刚刚读过这一条,即关于集中点的trick滴,它采用假装元素提供了有趣的做法,但你可以很容易地将这些要素添加到标记中(它赢得了语气,但会发挥作用)。

http://css-tricks.com/14745-centering-in-the-unknown/





相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...