我如何为非洲黑人玩家制作两张牌,为白人玩家制作两张相同高度的牌所有这些牌都使用相同的等级也许有一种方法可以使其高度相同

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;发布于 2016-12-19 21:53:43
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%;
}<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>
发布于 2016-12-19 21:48:49
如果它们在同一行中,则可以对该行使用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);
});发布于 2019-08-06 02:13:34
.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时,它默认是flex-direction:。
然后简单地在容器上添加align-items: stretch ...
这使得我的卡片具有相同的高度。(此解决方案仅在行设置为 flex-direction 时有效)
希望这能有所帮助
https://stackoverflow.com/questions/41223964
复制相似问题