SPAN紧挨着没有浮动

时间:2022-04-22 11:58:47

How would you get three span's to sit side by side instead of going to the next line without using float in CSS? so I need all three of these to appear next to each other..or if there is another method without using float. THanks!

如果不在CSS中使用float,你会如何得到三个并排坐在一起而不是下一行?所以我需要所有这三个看起来彼此相邻..或者如果有另一种方法没有使用浮点数。谢谢!

<span style="display:block; width:33%;">Test1</span>
<span style="display:block; width:33%;">Test2</span>
<span style="display:block; width:33%;">Test2</span>

3 个解决方案

#1


28  

display: inline-block; or their natural (default) display of inline.. though you can give the inline-block a width and height

display:inline-block;或者它们的内联自然(默认)显示..虽然你可以给内联块一个宽度和高度

#2


4  

Try display: inline-block; instead.

尝试显示:内联块;代替。

#3


1  

Yeah By Default Spans will show up next to each other, it all depends on the width of the element containing them. If someone were to re-size the browser or you shrunk the containing div their would be a line break.

Yeah By Default Spans将彼此相邻显示,它取决于包含它们的元素的宽度。如果有人要重新调整浏览器的大小,或者你缩小了包含div,那么他们将是一个换行符。

#1


28  

display: inline-block; or their natural (default) display of inline.. though you can give the inline-block a width and height

display:inline-block;或者它们的内联自然(默认)显示..虽然你可以给内联块一个宽度和高度

#2


4  

Try display: inline-block; instead.

尝试显示:内联块;代替。

#3


1  

Yeah By Default Spans will show up next to each other, it all depends on the width of the element containing them. If someone were to re-size the browser or you shrunk the containing div their would be a line break.

Yeah By Default Spans将彼此相邻显示,它取决于包含它们的元素的宽度。如果有人要重新调整浏览器的大小,或者你缩小了包含div,那么他们将是一个换行符。