如何为非洲黑人球员和白人球员制作两张相同高度的牌所有这些牌都使用相同的牌可能有一种方法可以让它达到相同的高度
div.card {
overflow: hidden;
}
.card {
width: 100%;
padding: 9px 20px 9px 20px;
margin-bottom: 0px;
background: #ffffff;
box-shadow: 1px 1px 1px #dfdfdf;
box-sizing: border-box;
height: 100% !important;
答案 0 :(得分:3)
Flexbox在这里派上用场。注意最后一个元素(三个<br>
)比其他两个元素高,但它们都是相同的高度:
* { box-sizing: border-box; }
.container {
display: flex;
flex-flow: row wrap;
}
.card-wrap {
flex: 0 0 33.333%;
display: flex;
padding: 10px; /* gutter width */
}
.card {
box-shadow: 0 0 4px rgba(0,0,0,0.4);
flex: 0 0 100%;
}
&#13;
<div class="container">
<div class="card-wrap">
<div class="card"><br></div>
</div>
<div class="card-wrap">
<div class="card"><br></div>
</div>
<div class="card-wrap">
<div class="card"><br><br><br></div>
</div>
</div>
&#13;
答案 1 :(得分:2)
如果它们在同一行,则可以在该行上使用display:flex;flex-direction:row;
,但如果它们不在同一行,则可以使用jQuery执行此操作。下面的代码段将使class="card"
具有相同高度的每个div
$(document).ready(function (){
var maxHeight = 0;
for(i=0;i<$(".card").length;i++){
if($(".card").eq(i)){
var currentHeight = $(".card").eq(i).height();
if(currentHeight>=maxHeight){
maxHeight = currentHeight;
}
}
else{
break;
}
}
$(".card").height(maxHeight);
});
答案 2 :(得分:0)
.container {
width: 100%;/*whatever size you want your container*/
border: 3px solid teal;
display: flex; /*Make sure to call this on your container*/
align-items: stretch; /*stretches all cards same height*/
justify-content: space-around; /*some space between cards*/
}
.card {
width: 150px; /*or whatever size card you want*/
border: 2px solid red;
}
<div class="container">
<div class="card">
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.
</div>
<div class="card">
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.
</div>
<div class="card">
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
</div>
</div>
这是最适合我的情况,
我在卡的容器(不是卡本身)上设置了 display: flex
默认情况下,当您说 display: flex
,然后只需在容器上添加 align-items: stretch
...
这使我的卡具有相同的高度。 (仅当您将灵活方向设置为行时,此解决方案才有效)
希望这会有所帮助