-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfimg1.php
65 lines (62 loc) · 1.63 KB
/
cfimg1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<h2 id="cfimg1">Demo 1 - One image to another, on hover (transitions)</h2>
<h3>Plan</h3>
<ol>
<li>Put one image on top of the other</li>
<li>Change the opacity of the top image on hover</li>
</ol>
<h3>Demo</h3>
<style>
#cf {
position:relative;
height:281px;
width:450px;
margin:0 auto;
}
#cf img {
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#cf img.top:hover, #cf img.hover_effect {
opacity:0;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
}
</style>
<div id="cf" class="shadow">
<img class="bottom" src="/images/Stones.jpg" />
<img class="top hover" src="/images/Summit.jpg" />
</div>
<h3>Code</h3>
<p>First up, the HTML markup. Without CSS enabled, you just get two images. Remember to add alt text for production use.</p>
<pre class="prettyprint lang-html">
<div id="cf">
<img class="bottom" src="/tests/images/Stones.jpg" />
<img class="top" src="/tests/images/Summit.jpg" />
</div>
</pre>
<p>Then the CSS:</p>
<pre class="prettyprint lang-css">
#cf {
position:relative;
height:281px;
width:450px;
margin:0 auto;
}
#cf img {
position:absolute;
left:0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#cf img.top:hover {
opacity:0;
}
</pre>