gpt4 book ai didi

html - Flexbox 边距顶部 : auto not pushing item to bottom

转载 作者:搜寻专家 更新时间:2023-10-31 23:19:53 24 4
gpt4 key购买 nike

我希望 UL 将每个元素推到容器底部。我为该元素设置了 margin-top:auto 但它不起作用。我有另一个有效的演示,但这是我需要使用的演示。有什么帮助吗?

.featured-products-carousel {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin: 0 auto;
max-width: 1150px;
width: 80%;
}
.featured-products-carousel .item {
background-color: white;
padding: 20px;
align-items: stretch;
display: flex;
flex-direction: column;
margin: 10px;
padding: 0;
flex: 1 1 auto;
flex-wrap: wrap;
}
.featured-products-carousel .item h2 {
text-align: center;
padding: 8px 5px;
}
.featured-products-carousel .item .featured-product-description {
margin-bottom: auto;
}
.featured-products-carousel .item .featured-products-links {
margin-top: auto;
}
.featured-products-carousel .item ul {
margin-top: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="featured-products-carousel" role="listbox">
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>

</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>


</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>

</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>


</div>
</div>

最佳答案

父元素不是 display: flex;,即使你已经指定了它,因为还有另一个规则用 display: block!important; 覆盖它。

  • display: block!important 来自第 6636 行的 bootstrap.css 和第 6554 行的另一个。

.featured-products-carousel {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin: 0 auto;
max-width: 1150px;
width: 80%;
}
.featured-products-carousel .item {
background-color: white;
padding: 20px;
align-items: stretch;
display: flex!important;
flex-direction: column;
margin: 10px;
padding: 0;
flex: 1 1 auto;
flex-wrap: wrap;
}
.featured-products-carousel .item h2 {
text-align: center;
padding: 8px 5px;
}
.featured-products-carousel .item .featured-product-description {
margin-bottom: auto;
}
.featured-products-carousel .item .featured-products-links {
margin-top: auto;
}
.featured-products-carousel .item ul {
margin-top: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="featured-products-carousel" role="listbox">
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>

</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>


</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>

</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] &nbsp; </h2>
</span>


<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">

</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>

<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id]&nbsp;»
</a>
</li>
<li>
<a href="[product-id].pdf">Datasheet</a>
</li>
</ul>


</div>
</div>

关于html - Flexbox 边距顶部 : auto not pushing item to bottom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43879601/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com