【发布时间】:2026-02-06 22:25:01
【问题描述】:
所以我想缩小一个 div,但是当我这样做时,它仍然占用相同数量的空间,但只有空白,然后它在中间很小。
但我希望它实际上占用更少的空间,并让上面和下面的元素更接近它。
这是问题的一个例子: HTML:
<h1>A title goes here</h1>
<div>
<span>Some text here</span><br>
<span>Some text here</span><br>
<span>Some text here</span><br>
<span>Some text here</span><br>
<span>Some text here</span><br>
<span>Some text here</span><br>
</div>
<p>And some more text here</p>
CSS:
div{
width: fit-content;
transform: scale(0.5);
}
代码笔:
【问题讨论】:
-
你不能用比例做这个,你需要减少宽度/高度
-
是的,它解释了为什么会这样,但我仍然不知道该怎么办