[英]How do you deal with layout columns that have different height?
To be specific, my problem is that I have a 2-column layout page, that depending on how long the article text is, might make the right side too out of place since if for example the article text on the left side is too short, it will make the right side too long. 具体来说,我的问题是我有一个两列的布局页面,该页面取决于文章文字的长度,可能会使右侧的位置太不合适,因为例如,如果左侧的文章文字太短, ,这会使右侧过长。
It's actually okay if the left side will be longer than the right side but not good if otherwise. 如果左侧的长度比右侧的长度长,实际上是可以的,但如果不是这样,则不好。
So probably my question is, in the event that the right column is way longer than the left column, what do you usually do to make the right column stop scrolling when its maximum height is reached while the left one is still scrolling? 因此,大概我的问题是,如果右列的长度比左列长,那么通常如何使右列停止滚动,直到达到最大高度,而左列仍在滚动?
You can use display: flex
to specify how much width each article column should take up: 您可以使用
display: flex
来指定每个文章列应占用的宽度:
.container { display: flex; } .a1 { background: orange; flex: 1; } .a2 { background: red; flex: 1; }
<div class="container"> <article class="a1"> <h1>Article 1</h1> <p>This is some text for article one, it does not change the size of the article!</p> </article> <article class="a2"> <h1>Article 2</h1> <p>This is some text for article two, it does not change the size of the article! Yay!!!!</p> </article> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.