简体   繁体   English

如何在调整文字大小时确保项目保持相同高度?

[英]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). (根据您的利益调整值-请注意,仅将pborder添加为高度的参考)。

---> JSFiddle <--- ---> JSFiddle <---

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM