[英]How to make sure items stay at the same height while resizing text?
If the window resizes the text "pushes itself" and the buttons get pushed down. 如果窗口调整了文本大小,则“按下自身”并且按钮被按下。
The button
s are all over the place. button
s到处都是。 I want the buttons to be at the same place. 我希望按钮在同一位置。
Check external fiddle to be able to resize to desktop 检查外部小提琴以将其调整为桌面大小
The issue is your button
s will place themselves in reference to text content. 问题是您的button
将自己放置在文本内容的引用中。
EDIT: I just noticed you were using flex, so why not take advantage of it. 编辑:我只是注意到您正在使用flex,所以为什么不利用它。
Solution 1: flexbox 解决方案1: flexbox
---> JS Fiddle <--- ---> JS小提琴<---
Solution 2: min-height
解决方案2: min-height
You could set a min-height
value on p
similar to the longest text, for example in the fiddle I used 180px
, but note you may have gaps between button
s and text if the latter is very short and this will also vary depending on the viewport's width, since if reduced will shrink text and push it down overflowing the min-height
, try to find a balance. 您可以在p
上设置一个min-height
值,该长度类似于最长的文本,例如在我使用的小提琴中为180px
,但是请注意,如果button
s和文本之间的距离很短,您可能会在button
s和文本之间留有间隔,并且该间隔也会根据视口的宽度,因为如果减小视口的宽度,则会缩小文本并将其向下推,从而使min-height
溢出,因此请尝试找到一个平衡点。
Add min-height
to section article p
. 将min-height
添加到section article p
。 (adjust value to your benefit - note that p
's border
was added simply as reference of the height). (根据您的利益调整值-请注意,仅将p
的border
添加为高度的参考)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.