gpt4 book ai didi

css - margin : auto is not centering

转载 作者:技术小花猫 更新时间:2023-10-29 10:20:26 26 4
gpt4 key购买 nike

以下样式来自网站:http://6.470.scripts.mit.edu/css_exercises/exercise4.html

<style type="text/css">
#sponsors {
margin:auto;
margin-top:50px;
overflow: hidden;
width: auto;
display: inline-block;
}
div.image img {
margin: 3px;
border: 1px solid #ffffff;
}
div.image a:hover img {
border: 1px solid;
}
</style>
</head>
<body>
<h1>Sponsors of 6.470</h1>
<div id="sponsors">
<div class="image"><a href=""><img src="images/appian.png" width="150" height="85"></a></div>
<div class="image"><a href=""><img src="images/dropbox.png" width="150px" height="85px"></a></div>
<div class="image"><a href=""><img src="images/facebook.png" width="150px" height="85px"></a></div>
<div class="image"><a href=""><img src="images/nextjump.png" width="150px" height="85px"></a></div>
<div class="image"><a href=""><img src="images/palantir.png" width="150px" height="85px"></a></div>
<div class="image"><a href=""><img src="images/quora.png" width="150px" height="85px"></a></div>
<div class="image"><a href=""><img src="images/tripadvisor.png" width="150px" height="85px"></a></div>
<div class="image"><a href=""><img src="images/vecna.png" width="150px" height="85px"></a></div>
</div>
</body>

如果width: auto#sponsors 中删除然后是 div#sponsors即使 margin: auto 也未居中对齐用来。

同样,如果不是text-align: centermargin: auto 取代在上面的体型中,然后是<h1>不会居中对齐,这是荒谬的;

因为我用过margin: auto很多次,它能够毫无问题地将内容居中。因此,请帮助我,我将非常感激。

PS:我使用的是 firefox,此外还使用了 doctype标记它仍然无法与 margin: auto 居中.

最佳答案

在您的#sponsors ID 上定义widthmargin

像这样

#sponsors{
margin:0 auto; // left margin is auto, right margin is auto , top and bottom margin is 0 set
width:1000px; // define your width according to your design
}

更多关于 margin auto

关于css - margin : auto is not centering,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15697830/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com