我正在Bootstrap / Html / Css中开发站点的前端...当前我在CSS中面临一个小问题。我已经使用引导卡创建了两张卡,并且我试图在这两张上应用叠加效果或翻转效果卡...我不知道在两张卡上应用这种切换效果的最简单方法是什么。
我们非常感谢与Css或Jquery相关的任何帮助。
这是我的卡片自举代码:
<div class="col-sm-6">
<div class="today-special">
<h4>Today Special</h4>
<div class="row">
<div class="col-sm-6">
<div class="card card-one">
<img class="card-img-top" src="images/320x210.png" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Pizza Marinara</h5>
<p class="card-text">80.96</p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card card-two">
<img class="card-img-top" src="images/320x210.png" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Chicken Noodles</h5>
<p class="card-text">50.10</p>
</div>
</div>
</div>
</div>
</div>
</div>
卡片的CSS:
.today-special{
text-align: left;
.card-one{
width:14rem;
border: 1px solid #888888;
border-radius: unset;
box-shadow: 4px 5px 15px 1px #888888;
.card-text{
color: #FEA200;
font-weight: 500;
}
}
.card-two{
width:14rem;
border: 1px solid #888888;
border-radius: unset;
box-shadow: 4px 5px 15px 1px #888888;
.card-text{
color: #FEA200;
font-weight: 500;
}
}
.card-img-top{
border-radius: unset;
}
}
当前我的两个引导卡如下:
我需要这些卡片看起来像这样:
答案 0 :(得分:0)
为包装DIV添加阴影,
在:hover
上,将当前.card
的z-index增量,并同时添加阴影
.card{
&-wrapper {
padding: 0;
box-shadow: 0 10px 60px 0 rgba(0,0,0,0.2);
}
z-index: 1;
border-radius: unset;
border: 0;
transition: 0.4s;
&:hover {
transform: scale(1.1);
box-shadow: 0 10px 40px 0 rgba(0,0,0,0.4);
z-index: 2;
}
&-text{
color: #FEA200;
font-weight: 500;
}
&-img-top{
border-radius: unset;
}
}
<link rel=stylesheet href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<div class="col-sm-6">
<div class="today-special">
<h4>Today Special</h4>
<div class="row">
<div class="col-sm-6 card-wrapper">
<div class="card">
<img class="card-img-top" src="//placehold.it/320x210/0bf" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Pizza Marinara</h5>
<p class="card-text">80.96</p>
</div>
</div>
</div>
<div class="col-sm-6 card-wrapper">
<div class="card">
<img class="card-img-top" src="//placehold.it/320x210/f0b" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Chicken Noodles</h5>
<p class="card-text">50.10</p>
</div>
</div>
</div>
</div>
</div>
</div>