我找不到解决翻转正面和背面卡片自动高度的解决方案。尤其是在Firefox浏览器中。
$(".card").flip({
axis: 'y',
trigger: 'hover'
});
.card {
height: auto;
width: 100%;
margin: 20px 0 30px 0;
}
.card .front, .card .back {
border: 1px solid #ccc;
border-radius: 20px;
padding: 10px;
height: auto !important;
}
.card .default{
background-color: white;
}
.card .back{
background-color: rgba(71, 207, 115, 0.1);
}
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="flipcard.css" />
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdn.rawgit.com/nnattawat/flip/master/dist/jquery.flip.min.js"></script>
</head>
<body>
<div class="template">
<div class="container">
<div class="row">
<div class="col-md-12">
<p>test content</p>
</div>
<hr>
<div class="col-md-4">
<div class="card">
<div class="front">
<p>Front</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <img src="https://dummyimage.com/mediumrectangle/222222/eeeeee" class="img-responsive img-rounded width-200 center-block" /><strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor </p>
</div>
<div class="back">
<p>Back</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue.
<strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="front">
<p>Front</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. </p>
</div>
<div class="back">
<p>Back</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="table-responsive">
<table class="table table-bordered">
<tbody>
<tr>
<td>
<div class="card">
<div class="front">
<p>Front</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
<div class="back">
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <img src="https://dummyimage.com/mediumrectangle/222222/eeeeee" class="img-responsive img-rounded width-200 center-block" />
<strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
</td>
</tbody>
</table>
</div>
</div>
<hr>
<div class="col-md-12">
<p>test content</p>
</div>
</div>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
以上代码基于JQuery和JS。在响应模式下,它与以下内容重叠。
如果有解决方案会更有用。
谢谢。
答案 0 :(得分:0)
您可以使用flexbox并依靠其默认的Stretch属性将两个元素的高度保持相等。您还需要调整一些CSS,并使用!important
覆盖JS添加的某些内联样式。
$(".card").flip({
axis: 'y',
trigger: 'hover'
});
.card {
display:flex;
width: 100%;
margin: 20px 0 30px 0;
}
.card .front, .card .back {
border: 1px solid #ccc;
border-radius: 20px;
padding: 10px;
position:relative!important;
height:auto!important;
}
.card .front {
margin-right:-100%;
}
.card .default{
background-color: white;
}
.card .back{
background-color: rgba(71, 207, 115, 0.1);
}
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="flipcard.css" />
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdn.rawgit.com/nnattawat/flip/master/dist/jquery.flip.min.js"></script>
</head>
<body>
<div class="template">
<div class="container">
<div class="row">
<div class="col-md-12">
<p>test content</p>
</div>
<hr>
<div class="col-md-4">
<div class="card">
<div class="front">
<p>Front</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <img src="https://dummyimage.com/mediumrectangle/222222/eeeeee" class="img-responsive img-rounded width-200 center-block" /><strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor </p>
</div>
<div class="back">
<p>Back</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue.
<strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="front">
<p>Front</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. </p>
</div>
<div class="back">
<p>Back</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="table-responsive">
<table class="table table-bordered">
<tbody>
<tr>
<td>
<div class="card">
<div class="front">
<p>Front</p>
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
<div class="back">
<p>Lorem ipsum dolor sit amet. Ut non quam in nisi molestie vulputate. Etiam ornare est in ipsum elementum, nec sodales lacus congue. <img src="https://dummyimage.com/mediumrectangle/222222/eeeeee" class="img-responsive img-rounded width-200 center-block" />
<strong>Praesent non tristique arcu.</strong> Sed a viverra nulla. Nunc vehicula orci risus, a pellentesque metus hendrerit a. Duis at lorem tortor. </p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<hr>
<div class="col-md-12">
<p>test content</p>
</div>
</div>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>