简体   繁体   English

如何处理高度不同的布局列?

[英]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.

相关问题 如何使html元素的高度与文本的高度相同? - How do you make an html element have the same height as the text? 如何使两个bootstrap 3列具有相同的高度? - How do I make two bootstrap 3 columns have the same height? 您如何处理小数(,)和javascript? - How do you deal with decimal (,) and javascript? 如何创建pinterest样式的布局,但项目具有不同的宽度,相同的高度 - How to create a pinterest-style layout, but where the items have different widths, same height 如何让元素按父级的高度在列中流动 - How to have elements flow in columns by height of parent 你如何布置DIV列? (或者,我做错了什么) - How do you layout columns of DIVs? (or, what am I doing wrong) 您如何处理库的小胡子表达式中的换行符 - How do you deal with line breaks in libraries' mustache expressions 如何在d3.js的实心圆布局的不同级别上增加填充? - How do you increase padding at different levels of d3.js's packed circle layout? 如何删除ID相同但显示属性不同的div - How do you delete divs that have the same ids but their dispaly properties are different 使用bootstrap 3,你如何拥有一个完全不同的移动导航栏,而不是响应? - Using bootstrap 3, how do you have a completely different navbar for mobile rather than responsive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM