gpt4 book ai didi

html - margin : 0 auto; not centering because there are divs to the left and right

转载 作者:太空宇宙 更新时间:2023-11-04 13:19:29 24 4
gpt4 key购买 nike

我试图使中间圆居中,但即使设置为 margin: 0 auto 我也无法做到;并显示:内联 block ;或显示表。有什么建议吗?

JSFiddle

HTML

<div id="intro">
<p class="body">As part of Science World’s Cycle Safe Initiative we have installed sensors at each of our gates. In the past year we have had over <b>300,000</b> people ride along. Some information we gathered for June included;</p>
<span class="blue circle">
<h3>2 - 3PM</h3>
<p>is the busiest hour</p>
</span>
<span class="green circle">
<h3>117,295</h3>
<p>riders this month</p>
</span>
<span class="navy circle">
<h3>10%</h3>
<p>of Vancouverites*</p>
</span>
</div>

CSS

#intro {
max-width: 1080px;
margin: 0 auto;
}
#intro .circle {
min-width: 230px;
min-height: 230px;
display: inline-block;
text-align: center;
border-radius: 1000px;
color: white;
margin: 60px 0;
}
#intro .circle h3 {
margin-top: 80px;
margin-bottom: 0;
font-size: 2.2em;
}
#intro .circle p {
margin-top: 0;
}
#intro .circle.blue {
background: #0079c8;
}
#intro .circle.green {
background: #2ecc71;
}
#intro .circle.navy {
background: #34495e;
float: right;
}

最佳答案

text-align:center 添加到 #intro(因为您的内部内容就像内联一样)并将 float:left 添加到您的#intro .circle.blue

Example

关于html - margin : 0 auto; not centering because there are divs to the left and right,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24174982/

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