我有<hr/>
标签,应根据<hr/>
标签下面的文字动态增加其大小。
<div class="outer">
<hr class="line"/>
The above line should be match with this sentence.
</div>
建议。
答案 0 :(得分:3)
将inline-block
添加到外部div
示例1:
.outer {
display: inline-block;
}
<div class="outer">
<hr class="line"/>
The above line should be with this sentence.
</div>
示例2:
.outer {
display: inline-block;
}
<div class="outer">
<hr class="line"/>
short text
</div>
答案 1 :(得分:1)
您可以通过将width: fit-content
添加到outer
类中来实现。
.outer {
width: fit-content;
}
<div class="outer">
<hr class="line"/>
The above line should be match with this sentence.
</div>
编辑:为了获得更好的浏览器支持,您可以改用display: table
。
.outer {
display: table;
}
<div class="outer">
<hr class="line"/>
The above line should be match with this sentence.
</div>