2013-03-09 53 views
0

我怎么能水平的容器放置在屏幕的中央屏幕分辨率屏幕中央的。该容器有8个图像被放置。所有的图像将被对齐到一行,并相应地改变屏幕分辨率。放置一个div来根据每个浏览器

这里是我的HTML

<div id="container"> 
    <div id="list" > 
     <img src="img/c1.png" style="display:box; width:125px; margin-left:5px; margin-top:9px" /> 
     <img src="img/c2.png" style="display:box; width:125px;margin-left:5px;margin-top:9px"/> 
     <img src="img/c3.png" style="display:box; width:125px;margin-left:5px;margin-top:9px" /> . 
     . 
     . 
    </div> 
</div> 

CSS:

#container{margin-left: auto;margin-right:auto;width:1200px;} 
+3

问题在哪里?它只是工作。 – BackSlash 2013-03-09 11:58:01

+0

就以http://stackoverflow.com/questions/114543/how-to-center-a-div-in-a-div-horizo​​ntally – user1929959 2013-03-09 11:58:01

+0

看看是否要在水平和垂直居中呢? – soyuka 2013-03-09 12:00:22

回答

2

在这里,你的CSS改善

这里的图像将表现为文本,以便该代码是完美的您的要求。 (如果你想要的东西不能正常工作,只留下你的HTML和CSS的jsfiddle,以便我们可以选择实时代码。)

#container { 
    position: relative; 
    margin: auto; 
    width:1200px; 
} 

#list img { 
    display: inline-block; 
} 

#list { 
    vertical-align: middle; 
    text-align: center; 
}