Html 我如何将两个圆形的div相邻放置?
基本上,我试着把两个圆圈放在一个容器内,彼此相邻(而不是在顶部) 然而,他们之间有一个空间,我想摆脱它。如何将两个(或多个)圆放在一起Html 我如何将两个圆形的div相邻放置?,html,css,Html,Css,基本上,我试着把两个圆圈放在一个容器内,彼此相邻(而不是在顶部) 然而,他们之间有一个空间,我想摆脱它。如何将两个(或多个)圆放在一起 谢谢大家的帮助看起来CSS中缺少的只是容器上的浮点:left。圆圈{规则 已更新 对于居中问题(来自注释)的一个潜在解决方案可能是将.containerdiv设置为圆圈的大小,并将其居中 .container { position: relative; margin: 0 auto; line-height: 50px; width:
谢谢大家的帮助看起来CSS中缺少的只是
容器上的浮点:left
。圆圈{
规则
已更新
对于居中问题(来自注释)的一个潜在解决方案可能是将.container
div设置为圆圈的大小,并将其居中
.container {
position: relative;
margin: 0 auto;
line-height: 50px;
width: 100px;
}
.container .circle {
height: 50px;
width: 50px;
background-color: blue;
border-radius: 50%;
text-align: center;
display: block;
margin: 0 auto;
float: left;
}
或者,按照其他人的建议,使用显示:内联块
,然后在容器上设置文本对齐:居中
.container {
position: relative;
margin: 0 auto;
line-height: 50px;
text-align: center;
}
.container .circle {
height: 50px;
width: 50px;
background-color: blue;
border-radius: 50%;
text-align: center;
display: inline-block;
margin: 0 auto;
}
看起来CSS中缺少的只是.container.circle{
规则上的float:left
已更新
对于居中问题(来自注释)的一个潜在解决方案可能是将.container
div设置为圆圈的大小,并将其居中
.container {
position: relative;
margin: 0 auto;
line-height: 50px;
width: 100px;
}
.container .circle {
height: 50px;
width: 50px;
background-color: blue;
border-radius: 50%;
text-align: center;
display: block;
margin: 0 auto;
float: left;
}
或者,按照其他人的建议,使用显示:内联块
,然后在容器上设置文本对齐:居中
.container {
position: relative;
margin: 0 auto;
line-height: 50px;
text-align: center;
}
.container .circle {
height: 50px;
width: 50px;
background-color: blue;
border-radius: 50%;
text-align: center;
display: inline-block;
margin: 0 auto;
}
使用display:inline block;
代替display:block;
并给容器留出边距:0 5px;
。圈出以留出间距
您也可以使用float:left
.container .circle {
height: 50px;
width: 50px;
background-color: blue;
border-radius: 50%;
text-align: center;
display: inline-block;
margin: 0 5px;
}
使用显示:内联块;
而不是显示:块;
并给容器留出边距:0 5px;
。圈出以留出间距
您也可以使用float:left
.container .circle {
height: 50px;
width: 50px;
background-color: blue;
border-radius: 50%;
text-align: center;
display: inline-block;
margin: 0 5px;
}
尝试将浮点添加到.container.circle
float:left
选中此项尝试将浮点添加到.container.circle
float:left
检查此项已更新:
可选:
用于两个圆的重叠。请查看
第二种方式:
HTML:
已更新:
可选:
用于两个圆的重叠。请查看
第二种方式:
HTML:
您只需将float:left;添加到circle类中即可。为了保证良好的对齐,我建议固定容器的宽度和高度,并将:height:100%设置为圆,请检查链接:
您只需将float:left;添加到circle类中即可。为了保证良好的对齐,我建议固定容器的宽度和高度,并将:height:100%设置为circle,请检查链接:
您可以在容器2分区内使用
把你的代码放在2div列中,它很容易启动,但是你需要在你的.html页面中有一个启动css链接
您可以在容器2分区内使用
把你的代码放在2div列中,它很容易启动,但是你需要在你的.html页面中有一个启动css链接
如果要将它们居中,请将.container的宽度更改为.container{
明确:两者皆有;
溢出:隐藏;
宽度:23%;}
如果要使它们居中,请将.container的宽度更改为.container{
明确:两者皆有;
溢出:隐藏;
宽度:23%;}
在圆div中使用左浮动
.container .circle {float:left;}
检查此使用圆圈div中的左浮动
.container .circle {float:left;}
检查这个只需将float left添加到.container.circle css中,就像.container.circle{float:left}如果你想在这些div之间留出一些空间,请加上边距。对不起,还有一件事。我怎样才能使它位于中间page@user1354934如果你想让圆圈在页面中间居中,你有几个选项,其中之一就是把圆圈放在另一个子容器div中,然后把它放在.container的中心,或者,如果可能的话将容器设置为两个圆圈的大小并居中(参见更新的答案),只需将float left添加到.container.circle css like.container.circle{float:left}如果你想在这些div之间留出一些空间,请加上边距。对不起,还有一件事。我怎样才能使它位于中间page@user1354934如果你想让圆圈在页面中间居中,你有几个选项,其中之一就是把圆圈放在另一个子容器div中,然后把它放在.container的中心,或者,如果可能的话将容器设置为两个圆圈的大小和中心(请参见更新的答案)谢谢这不是我想要的,但这对nkow很好!哦,我明白了。现在更新了,请看这个。:)谢谢这不是我想要的,但这对nkow很好!哦,我明白了。现在更新了,请看这个。:)谢谢!!!!!!!!!!!!!!