html – d性项目的等高儿童

html – d性项目的等高儿童,第1张

概述我在创建一个flexbox响应网格时遇到了问题,并希望有人可以指出我正确的方向. 我希望所有的.block div都是相同的高度,而.bottom div绝对位于底部.这实际上是在当前的解决方案中工作,但是当h2标题太长并且达到2行时,我希望该行的所有h2标题都是相同的高度. 这有可能吗? 我做了一个Codepen来说明问题: http://codepen.io/kenvdbroek/pen/eZ 我在创建一个flexBox响应网格时遇到了问题,并希望有人可以指出我正确的方向.

我希望所有的.block div都是相同的高度,而.bottom div绝对位于底部.这实际上是在当前的解决方案中工作,但是当h2标题太长并且达到2行时,我希望该行的所有h2标题都是相同的高度.

这有可能吗?

我做了一个Codepen来说明问题:
http://codepen.io/kenvdbroek/pen/eZKdEQ

h1,h2,h3 {  margin: 0;}body {  margin: 0;  padding: 0;}ul.clean-List {  margin: 0;  padding: 0;}ul.clean-List li {  List-style: none;  margin-bottom: 5px;}li:last-child {  margin-bottom: 0;}.container {  padding-top: 50px;}.block {  margin-bottom: 30px;  border: 1px solID red;}.block > .bottom {  border: 1px solID blue;}@media only screen and (min-wIDth: 480px) {  .row.row-flex-wrapper::before,.row.row-flex-wrapper::after {    content: none !important;  }  .row.row-flex-wrapper::after {    clear: none;  }  .row.row-flex-wrapper {    display: -webkit-flex;    display: -ms-flexBox;    display: flex;    flex-wrap: wrap;    -webkit-flex-wrap: wrap;    -ms-flex-wrap: wrap;  }  .row.row-flex-wrapper .column {    display: -webkit-flex;    display: -ms-flexBox;    display: flex;    float: none;    border: 1px solID orange;  }  .row.row-flex-wrapper .column > .block {    display: -webkit-flex;    display: -ms-flexBox;    display: flex;    flex-direction: column;    -ms-flex-direction: column;    -webkit-flex-direction: column;  }  .row.row-flex-wrapper .column > .block > .block-List {    flex: 1 0 auto;    -ms-flex: 1 0 auto;    -webkit-flex: 1 0 auto;  }  .row.row-flex-wrapper .column > .block > h2 {}}@media only screen and (min-wIDth: 480px) and (max-wIDth: 767px) {  .container .row .column {    wIDth: 50%;  }}
<div >  <div >    <div >      <div >        <h2>Title 1</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unkNown printer took a galley of type and scrambled it to make a type specimen book.            It has survived not only five centurIEs,but also the leap into electronic typesetting,remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,and more recently            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>        </div>        <div >          <ul >            <li><a href="/button">Some link</a>            </li>            <li><a href="/button">Some link 2</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>Another very long Title which is actually toooo long...</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unkNown printer...</p>        </div>        <div >          <ul >            <li><a href="/another-button">Another button</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>Title</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unkNown printer,Lorem Ipsum has been the industry's standard dummy text...</p>        </div>        <div >          <ul >            <li><a href="/button">Very nice link</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>This block is cool!</h2>        <div >          <p>Some text here. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,Lorem Ipsum has been the industry's standard dummy            text...</p>        </div>        <div >          <ul >            <li><a href="/button">Another link</a>            </li>            <li><a href="/button">Check this item</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>Title Block</h2>        <div >          <p>Go check out this item... Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,Lorem Ipsum has been the industry's standard            dummy text...</p>        </div>        <div >          <ul >            <li><a href="/button">button</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>buttonssssss</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,and more recently            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>        </div>        <div >          <ul >            <li><a href="#button">button</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>Title</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>        </div>        <div >          <ul >            <li><a href="/button">link to item</a>            </li>            <li><a href="/button">link to item</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>Title</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,and more recently            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>        </div>        <div >          <ul >            <li><a href="/button">link to item</a>            </li>          </ul>        </div>      </div>    </div>    <div >      <div >        <h2>Another very very very very very very very long Title</h2>        <div >          <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,and more recently            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>        </div>        <div >          <ul >            <li><a href="/button">button to item</a>            </li>          </ul>        </div>      </div>    </div>  </div></div>
解决方法 一般来说,这对于flexBox或CSS是不可能的.

flex容器的初始设置是align-items:stretch.这会导致d性项目扩展到cross axis的全长.这就是所谓的“d性相等高度列”.

以下是一些要记住的注意事项:

>等高列仅适用于Flex容器的子项.换句话说,flex项必须具有相同的父项.否则,等高特征不适用.

你的问题:

I want all the h2 headings of the row to be the same height. Is this possible in some way?

不是用CSS.因为h2存在于不同的容器中,它们不是兄弟姐妹(它们更像堂兄弟),所以不同的高度不适用.
> flexBox中的等高柱仅适用于一条柔性线.通过包装创建的其他线上的项目建立自己的相等高度线.这意味着equal height columns do not work in a multi-line flex container.
> align-self属性可用于单个d性项目以覆盖对齐项目,这可能会破坏相等高度的特征.
>通过在d性项目上指定高度(例如,高度:300px),将覆盖该项目的align-items和align-self,并忽略相等的高度设置.
>这篇文章重点介绍一个具有flex-direction:row的容器.如果容器是flex-direction:column,则相等的高度变为相等的宽度.这是一个详细的评论:Make flex items take content width,not width of parent container

有关:

> Equal height rows in a flex container
> How to disable equal height columns in Flexbox?

总结

以上是内存溢出为你收集整理的html – d性项目的等高儿童全部内容,希望文章能够帮你解决html – d性项目的等高儿童所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1138915.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存