div 中的两个 span 彼此相邻且不浮动
我在一个div中有两个span。我想将它们彼此对齐。我通过将它们向左和向右浮动来做到这一点。问题是这些跨度具有可变的高度(当您单击“更多选项”时它们会向下滑动)。因此,当它们的高度在运行时发生变化(通过向下滑动)时,它们不会向下推其下方的元素。如果有一种方法可以在不浮动的情况下对齐它们,那就行了。
I've got two spans in a div. I want to align them next to each other. I'm doing this by floating them both left and right. The problem is that these spans have variable heights (they slide down when you click for 'more options'). So when their heights are changed during runtime (by sliding down), they won't push down the elements under them. If there's a way to align them without floating them, that would work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许这些跨度后面带有“clear:both”的元素可以解决您的问题?
Maybe an element with "clear:both" after those spans will solve your problem?
将
overflow:auto
或overflow:hidden
放在您的 div 上。这将强制 div 的大小适应内部浮动内容。Put
overflow:auto
oroverflow:hidden
on your div. This will force the div to size to the floating contents inside.冒着获得大量反对票的风险,使用
?
At the risk of getting massive downvotes, use a
<table>
?