gpt4 book ai didi

html - 当 block 不适合此内联时自动高度内联

转载 作者:太空宇宙 更新时间:2023-11-04 02:51:36 26 4
gpt4 key购买 nike

我在 p 中有一些应该右对齐的“ block ”:

<p>text at line
<span style="display: block; float: right">
<span class="tag">
tag1
</span>
<span class="tag">
tag2
</span>
<span class="tag">
tag3
</span>
</span>
</p>
<hr>
Some text after hr

CSS:

.tag {
background-color:red;
margin-right: 10px;
padding:5px;
}

好吧,但在小屏幕上我有一些问题:

enter image description here

https://jsfiddle.net/3pcjqww0/

最佳答案

p 更改为 div,并添加以下样式:

div {
line-height: 1.8em; //this prevents the tags from overlapping the text on small screens
}

hr {
clear: both; //this keeps the horizontal rule at 100% width
}

Fiddle

关于html - 当 block 不适合此内联时自动高度内联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32896388/

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