我有一组图像,我想要的是能够翻转图像。在图像的前面,它将显示数字(请参见下图),在背面,将显示图片。如果用户单击另一张图像并且它与单击的第一张图片匹配,那么它将在几秒钟后消失。现在,我一直坚持要翻转图像。我将在下面粘贴我的html代码和CSS。
为了使图像翻转,我尝试使用悬停效果,但这也不起作用
#flipper:hover {
transform: rotateY(180deg);
}
body {
color: black;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
h2 {
text-align: center;
}
body {
background-color: white;
}
img {
width: 30%;
float: left;
margin: 1.66%;
}
p {
margin-left: 1.66%;
font-family: "Contrail One", cursive;
font-size: 35px;
text-transform: uppercase;
border-bottom: 2px solid black;
width: 30%;
padding-bottom: 20px;
}
div.a {
text-align: center;
font-family: sans-serif;
}
#flipper:hover {
transform: rotateY(180deg);
}
<link href="https://fonts.googleapis.com/css?family=Contrail+One" rel="stylesheet">
<div id="flipper">
<img class="flip" src="http://c1.staticflickr.com/9/8450/8026519634_f33f3724ea_b.jpg" alt="">
<img src="http://c1.staticflickr.com/9/8450/8026519634_f33f3724ea_b.jpg" alt="">
<img src="http://c2.staticflickr.com/8/7218/7209301894_c99d3a33c2_h.jpg " alt="">
<img src="http://c2.staticflickr.com/8/7218/7209301894_c99d3a33c2_h.jpg " alt="">
<img src="http://c2.staticflickr.com/8/7231/6947093326_df216540ff_b.jpg " alt="">
<img src="http://c2.staticflickr.com/8/7231/6947093326_df216540ff_b.jpg " alt="">
<img src="http://c1.staticflickr.com/9/8788/17367410309_78abb9e5b6_b.jpg " alt="">
<img src="http://c1.staticflickr.com/9/8788/17367410309_78abb9e5b6_b.jpg " alt="">
</div>
答案 0 :(得分:1)
我想首先要说的是,我无法告诉您是否已经将书面CSS链接到HTML。我只看到1个链接,而没有链接到您的CSS。看起来像Google字体。
我创建了一个https://codepen.io/robert9111/pen/MzabWZ
<!-- HTML -->
<div id="f1_container">
<div id="f1_card" class="shadow">
<div class="front face">
<img class="size" src="http://c1.staticflickr.com/9/8450/8026519634_f33f3724ea_b.jpg/">
</div>
<div class="back face center">
<p>This is nice for exposing more information about an image.</p>
<p>Any content can go here.</p>
</div>
</div>
</div>
<!-- CSS -->
#f1_container {
position: relative;
margin: 10px auto;
width: 450px;
height: 281px;
z-index: 1;
}
.size {
width: 450px;
height: 281px;
}
#f1_container {
perspective: 1000;
}
#f1_card {
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: all 1.0s linear;
}
#f1_container:hover #f1_card {
transform: rotateY(180deg);
box-shadow: -5px 5px 5px #aaa;
}
.face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
}
.face.back {
display: block;
transform: rotateY(180deg);
box-sizing: border-box;
padding: 10px;
color: white;
text-align: center;
background-color: #aaa;
}
供您结帐。我认为这可以解决您的问题。
我并没有全部做完,因为我认为写一些代码对您很有帮助。