【发布时间】:2015-11-17 12:00:44
【问题描述】:
不知道如何搜索,所以从头开始提问。
我有一个连续的四个图像块,悬停时会翻转到信息窗格,并带有指向该项目的链接。在移动设备和平板电脑网站上,这会通过两个图像流向两个图像。
我对完整桌面尺寸的外观和效果非常满意,但是除非我为 '.flip-容器'。但是,如果我有一个固定的高度,这意味着整个块没有正确地重排(而且我仍然有一些重叠)。
因此-我的主要问题是如何使“.flip-container”的高度响应其内容?这是在 Magento 中作为静态块运行的。
我遇到的另一个问题是这在 Safari 中确实无法正常工作(尽管在我尝试过的所有其他浏览器中都可以)。本质上,图像的反面仍在显示,信息窗格的阴影也是如此。任何建议表示赞赏。
代码/示例可能更容易解释自己...
非常感谢所有帮助。如果有人需要更多详细信息,请告诉我
实时示例(它是页面中的第二个内容块,有四个书籍封面):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;
}
【问题讨论】:
-
欢迎来到 StackOverflow。恐怕你必须为
.flip-container指定一个固定的高度,因为.front和.back有position:absolute,所以包装器-.flipper,不要为它们“保存”一个位置。你可以通过javascript修复它(如果你必须),我可以帮你解决这个问题。Safari使用哪个版本和操作系统? -
@MoshFeu 谢谢,这让(有点)更有意义。当我删除 .front 和 .back 上的绝对位置,并从 .flip-container 中删除高度时,整个批次都是可回流的,但只有 .back 低于 .front(组合高度)。因此,我需要使用 Javascript 来模拟“位置:绝对”的效果,以便 .back 出现在 .front 后面?非常感谢任何帮助或指示,因为我对 Javascript 没有太多经验。 Safari 版本是版本 9.0.1 (10601.2.7.2),在 OSX Yosemite 10.10.5 上。如果可以的话,我会在主帖中添加一些屏幕截图。
标签: html css magento-1.9