2013-04-09 126 views
0

我有4分格的:CSS重叠div的

#centered { 
    position: absolute; 
    top: 50%; 
    left: 52%; 
    width: 500px; 
    height: 500px; 
    margin-top: -250px; /* Half the height */ 
    margin-left: -250px; /* Half the width */ 
    } 
#container{ 
    width:100%; 
} 

(左和右是在该容器中)

#left{ 
     float:left; 
     width: 260px; 
     height: 600px; 
    } 
    #right{ 
     float: right; 
     top: 50%; 
     width: 160px; 
     height: 600px; 
    } 

中心的DIV总是在页面的中心,另外两个在两边。 使用

body { min-width:1150px; } 

#centered和#right之间总是有空格。 但是当我缩小页面时,#center和#left之间没有空间, 导致重叠。我怎样才能做到这一点?

+0

也给你的html代码 – 2013-04-09 13:38:31

回答

1

您可以添加一个排水沟<div>并相应地调整您的位置,或者您可以减小宽度#left。宽度为#left#right的宽度使用百分比而不是px,因此在调整大小时会更平滑。