[英]on hover and on click how to fade out image and fade in content text
I am using a JS Fiddle idea JSFIDDLE to implement a css image change within a div on hover and on click. 我正在使用JS Fiddle想法JSFIDDLE在悬停和单击时在div内实现CSS图像更改。
Below is my own code in which I have implemented this, however the image that fades in is a picture of text as I do not know how to fade out an image and fade in written content. 下面是我自己的代码,在其中实现了该代码,但是淡入的图像是文本的图片,因为我不知道如何淡出图像和淡入书面内容。 So is there any way to edit my code to fade in some content instead of fading in another image of text? 那么,有什么方法可以编辑我的代码以淡入某些内容,而不是淡入另一幅文本图像?
Thanks in advance. 提前致谢。
<div id="apDiv7"><div style="border-radius: 20px;" class="table-wrapper">
<div class="row row1">
<div class="column"><img src="topright.png" width="400" height="300" class="img1" /></div>
<div class="column"><img src="topcenter.png" width="400" height="300" class="img2" /></div>
<div class="column"><img src="topleft.png" width="400" height="300" class="img3" /></div>
</div>
<div class="row row2">
<div class="column"><p></p><img src="bottomleft.png" width="600" height="400" class="img4" /> </div>
<div class="column"><p></p><img src="bottomright.png" width="600" height="400" class="img5" /></div>
</div>
</div></div>
css CSS
.row:after {
display: block;
clear: both;
content: "";
}
.row1 .column {
width: 33.3333%;
}
.row2 .column {
width: 50%;
}
.column {
top: 20px;
float: left;
text-align: center;
}
#apDiv7 {
position: absolute;
width: 90%;
height: 700px;
left: 5%;
background-color: #FFFFFF;
border-radius: 20px;
border: 8px solid #666666;
}
Try this: JSFIDDLE 试试这个: JSFIDDLE
<div class="hover-img">
<img src="http://www.wholesaleforeveryone.com/content/images/blank/600/solid_color.gif" class="img1"/>
<p class="text">place holder text goes here</p>
</div>
.hover-img {
position: relative;
width: 200px;
height: 200px;
}
.hover-img > img {
position: absolute;
left: 0; top: 0;
width: 100%; height: 100%;
z-index: 19;
}
.hover-img > p {
position: absolute;
left: 0; top: 0;
width: 100%; height: 100%;
background-color: white;
margin: 0;
z-index: 9;
}
.hover-img > .img1 {
opacity: 1;
-webkit-transition: opacity 500ms ease-in-out;
-moz-transition: opacity 500ms ease-in-out;
-ms-transition: opacity 500ms ease-in-out;
-o-transition: opacity 500ms ease-in-out;
transition: opacity 500ms ease-in-out;
}
.hover-img > .text {
opacity: 0;
-webkit-transition: opacity 500ms ease-in-out;
-moz-transition: opacity 500ms ease-in-out;
-ms-transition: opacity 500ms ease-in-out;
-o-transition: opacity 500ms ease-in-out;
transition: opacity 500ms ease-in-out;
}
.hover-img:hover > .img1 {
opacity: 0;
}
.hover-img:hover > .text {
opacity: 1;
}
See if this solution works for you: 查看此解决方案是否适合您:
html HTML
<div class="hover-img">
Text Goes Here
</div>
css CSS
.hover-img {
position: relative;
width: 200px;
height: 200px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
background:url(http://www.wholesaleforeveryone.com/content/images/blank/600/solid_color.gif);
-webkit-transform:rotateY(180deg);/*requires vendor prefix*/
-webkit-transform-style: preserve-3d;/*requires vendor prefix*/
line-height:200px;
text-align:center;
font-size:0;
}
.hover-img:hover{
-webkit-transform:rotateY(0deg);/*requires vendor*/
font-size:14px;
color:white;
}
Should use vendor prefixes for the all the commented props 所有注释的道具都应使用供应商前缀
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.