图像翻转器没有回流高度
Image flipper not reflowing height
不知道如何搜索这个,所以从头开始提问。
我有一个连续四张图片块,悬停时会翻转到信息窗格,项目带有 link。这在移动和平板电脑网站上由两张图片向下流动到两张图片。
我对完整桌面尺寸的外观和效果非常满意,但是图像 运行 覆盖页面上剩余的内容(以及移动设备上的第二行图像),除非我指定一个固定的'.flip-container' 的高度。但是,如果我有一个固定的高度,这意味着整个块没有正确回流(而且我仍然有一些重叠)。
因此 - 我的主要问题是如何使“.flip-container”的高度响应其内容?这是 运行在 Magento 中作为静态块。
我遇到的另一个问题是,这在 Safari 中确实效果不佳(尽管在我尝试过的所有其他浏览器中都可以)。本质上,图像的反面仍在显示,信息窗格的阴影也是如此。任何建议表示赞赏。
code/example 自我解释可能更容易...
非常感谢大家的帮助。如果有人需要任何进一步的细节,请告诉我
实例(它是包含四个书籍封面的页面中的第二个内容块):http://bit.ly/1Mz2nQ0
这是HTML:
<div class="featured">
<div class="flip-left">
<div class="flip-container first-flip" style="margin-left: 0px;">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781785300080.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
<div class="flip-container">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781845029951.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
</div>
<div class="flip-right">
<div class="flip-container first-flip">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781845029890.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
<div class="flip-container" style="margin-right: 0px;">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781845029852.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
</div>
</div>
和 CSS:
* ============================================ *
* Image Flipper 4-column
* ============================================ */
.featured {
padding-top: 25px;
padding-bottom: 25px;
font-size:0;
}
.featured .flip-container img {
width: 100%;
box-shadow: 10px 10px 5px #888888;
}
.flip-left {
width:50%;
float: left;
}
.flip-right {
width:50%;
float:right;
margin-bottom:40px;
}
.flip-container {
width: 45.3125%;
height: 334px;
display: inline-block;
vertical-align: top;
margin-right: 3.125%;
margin-left: 3.125%
}
/* entire container, keeps perspective */
.flip-container {
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
transform: rotateY(180deg);
}
.back {
width: 100%;
}
.front {
width:100%;
}
/* flip speed goes here */
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
/* front pane, placed above back */
.front {
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
transform: rotateY(180deg);
background-color: $c-dark-grey;
padding: 20px;
box-shadow: 10px 10px 5px #888888;
}
/* Text Styles */
.featured .flipper .back {
h3 {
color: white;
}
h4 {
color: $c-gray;
}
}
.read-more button {
max-width: 90%;
background: $c-button;
padding: 5px;
color: white;
text-transform: uppercase;
margin-top: 10px;
border: none;
}
.read-more button:hover {
background: $c-button-hover;
}
/* Media Breakpoint */
@include bp(max-width, $bp-medium) {
.featured {
padding-bottom: 0px;
padding-top: 0px;
}
.flip-container {
width: 46.875%;
margin: 0 0 0 0px;
}
.flip-left .first-flip {
margin-right: 6.25%;
}
.flip-right .first-flip {
margin-right: 6.25%;
}
.flip-left {
width: 100%;
float: none;
margin-right: 0px;
margin-bottom: 40px;
}
.flip-right {
width:100%;
float: none;
.first {
margin-left:0px;
}
}
}
.team-wall .flip-right {
margin-bottom: 0px;
}
JavaScript 中使用 jQuery 的解决方案。
翻转效果来源:https://davidwalsh.name/css-flip
$('.flipper').each(function() {
var elem = $(this),
front = elem.find('.front');
elem.height(front.height());
});
* {
box-sizing: border-box;
}
/* entire container, keeps perspective */
.flip-container {
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container/*, .front, .back*/ {
width: 250px;
}
/* flip speed goes here */
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
width:100%;
}
/* front pane, placed above back */
.front {
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
transform: rotateY(180deg);
background-color: #a4a4a4;
padding: 20px;
box-shadow: 10px 10px 5px #888888;
height:100%; /* now, you can set this to 100%, because his parent - .flipper - has height*/
}
img {
display:block;
width:100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<img alt="Ursula's Secret, Mairi Wilson" src="http://testsite.itchycoo-education.com/media/wysiwyg/HOME/featured/9781785300080.jpg">
</div>
<div class="back">
<h3>Ursula's Secret</h3>
<h4>Mairi Wilson</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../ursula-s-secret.html"><button type="button">Read More</button></a></div>
</div>
</div>
</div>
<br /><br />
不知道如何搜索这个,所以从头开始提问。
我有一个连续四张图片块,悬停时会翻转到信息窗格,项目带有 link。这在移动和平板电脑网站上由两张图片向下流动到两张图片。
我对完整桌面尺寸的外观和效果非常满意,但是图像 运行 覆盖页面上剩余的内容(以及移动设备上的第二行图像),除非我指定一个固定的'.flip-container' 的高度。但是,如果我有一个固定的高度,这意味着整个块没有正确回流(而且我仍然有一些重叠)。
因此 - 我的主要问题是如何使“.flip-container”的高度响应其内容?这是 运行在 Magento 中作为静态块。
我遇到的另一个问题是,这在 Safari 中确实效果不佳(尽管在我尝试过的所有其他浏览器中都可以)。本质上,图像的反面仍在显示,信息窗格的阴影也是如此。任何建议表示赞赏。
code/example 自我解释可能更容易...
非常感谢大家的帮助。如果有人需要任何进一步的细节,请告诉我
实例(它是包含四个书籍封面的页面中的第二个内容块):http://bit.ly/1Mz2nQ0
这是HTML:
<div class="featured">
<div class="flip-left">
<div class="flip-container first-flip" style="margin-left: 0px;">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781785300080.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
<div class="flip-container">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781845029951.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
</div>
<div class="flip-right">
<div class="flip-container first-flip">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781845029890.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
<div class="flip-container" style="margin-right: 0px;">
<div class="flipper">
<div class="front"><img alt="Book Title, Author Name" src="{{media url="wysiwyg/HOME/featured/9781845029852.jpg"}}" /></div>
<div class="back">
<h3>Book Title</h3>
<h4>Author Name</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../book-url.html"> <button type="button">Read More</button></a></div>
</div>
</div>
</div>
</div>
</div>
和 CSS:
* ============================================ *
* Image Flipper 4-column
* ============================================ */
.featured {
padding-top: 25px;
padding-bottom: 25px;
font-size:0;
}
.featured .flip-container img {
width: 100%;
box-shadow: 10px 10px 5px #888888;
}
.flip-left {
width:50%;
float: left;
}
.flip-right {
width:50%;
float:right;
margin-bottom:40px;
}
.flip-container {
width: 45.3125%;
height: 334px;
display: inline-block;
vertical-align: top;
margin-right: 3.125%;
margin-left: 3.125%
}
/* entire container, keeps perspective */
.flip-container {
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
transform: rotateY(180deg);
}
.back {
width: 100%;
}
.front {
width:100%;
}
/* flip speed goes here */
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
/* front pane, placed above back */
.front {
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
transform: rotateY(180deg);
background-color: $c-dark-grey;
padding: 20px;
box-shadow: 10px 10px 5px #888888;
}
/* Text Styles */
.featured .flipper .back {
h3 {
color: white;
}
h4 {
color: $c-gray;
}
}
.read-more button {
max-width: 90%;
background: $c-button;
padding: 5px;
color: white;
text-transform: uppercase;
margin-top: 10px;
border: none;
}
.read-more button:hover {
background: $c-button-hover;
}
/* Media Breakpoint */
@include bp(max-width, $bp-medium) {
.featured {
padding-bottom: 0px;
padding-top: 0px;
}
.flip-container {
width: 46.875%;
margin: 0 0 0 0px;
}
.flip-left .first-flip {
margin-right: 6.25%;
}
.flip-right .first-flip {
margin-right: 6.25%;
}
.flip-left {
width: 100%;
float: none;
margin-right: 0px;
margin-bottom: 40px;
}
.flip-right {
width:100%;
float: none;
.first {
margin-left:0px;
}
}
}
.team-wall .flip-right {
margin-bottom: 0px;
}
JavaScript 中使用 jQuery 的解决方案。
翻转效果来源:https://davidwalsh.name/css-flip
$('.flipper').each(function() {
var elem = $(this),
front = elem.find('.front');
elem.height(front.height());
});
* {
box-sizing: border-box;
}
/* entire container, keeps perspective */
.flip-container {
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container/*, .front, .back*/ {
width: 250px;
}
/* flip speed goes here */
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
width:100%;
}
/* front pane, placed above back */
.front {
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
transform: rotateY(180deg);
background-color: #a4a4a4;
padding: 20px;
box-shadow: 10px 10px 5px #888888;
height:100%; /* now, you can set this to 100%, because his parent - .flipper - has height*/
}
img {
display:block;
width:100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<img alt="Ursula's Secret, Mairi Wilson" src="http://testsite.itchycoo-education.com/media/wysiwyg/HOME/featured/9781785300080.jpg">
</div>
<div class="back">
<h3>Ursula's Secret</h3>
<h4>Mairi Wilson</h4>
<h4>£7.99</h4>
<div class="read-more"><a href="../ursula-s-secret.html"><button type="button">Read More</button></a></div>
</div>
</div>
</div>
<br /><br />