Pre-knowledge
- DIV+CSS Foundation
- Transform and transition usage of CSS3
- Mostly with Transform's rotate/scale.
- Several parameters of the animation transition (transition-property/transition-duration/transition-timing-function)
- CSS3 's Box-shadow. It only uses the outer shadow.
Worth mentioning: More properties of the parameters to query the CSS manual, where the display is only used;
Material acquisition
Baidu self-search image material, replace the following code image path can be.
Examples of images larger than 400 pixels are less than 600 pixels, of which 480x270 is mostly
Effect description
Initialize the messy picture sort (CSS control), the mouse hover will let the picture in the top level display, and the picture restores the level display + enlarges 1.5 times times
Code implementation
Code contains comments
Index.html
<! DOCTYPE html><html lang="zh"><head> <meta charset="UTF-8"> <title>CSS3 Realization of Photo wall</title> <link rel="stylesheet" href="Css/style.css"> </head><body> <H1>Pure CSS3 realization Photo Wall</H1> <div id="container"> <img class="Position_pic1" src="img/1.jpg " Alt="This is a picture of Meimei"> <img class="Position_pic2" src="img/2.jpg" alt=" This is a Meimei picture "> <img class="position_pic3" src="img/3.jpg" alt ="This is a picture of a Meimei"> <img class="position_pic4" src="img/4.jpg" alt=" This is a Meimei picture "> <img class="position_pic5" src="img/5.jpg" alt ="This is a picture of a Meimei"> <img class="position_pic6" src="img/6.jpg" alt=" This is a Meimei picture "> <img class="Position_pic7" src="img/7.jpg" alt ="This is a picture of a Meimei"> <img class="Position_pic8" src="img/8.jpg" alt=" This is a Meimei picture "> </div></body></html>
Style.css
*{ margin: 0; padding: 0; Border: 0; outline: 0; }/ * Simplified version reset*/H1{ text-align: center;} / * Text centered * /#container{ position: relative; width: px; margin: 0 auto; }/ * Block Center * /#container img{ position: Absolute ; z-index: 1 ; -webkit-transition-timing-function: ease ; transition-timing-function: ease ; -webkit-transition-duration: 1s ; transition-duration: 1s ; -webkit-transition-property: All; transition-property: All; Border: 5px solid #eee ; box-shadow: 2px 2px 2px rgba (0, 0, 0,. 5) ;}/* Add a small Shadow (outer shadow) to the picture and add a border here transition separate parameters to write, convenient for small partners to understand. Of course, you can also use shorthand: Eg:tansition:all 0.5 ease-out position The function here is to offset the image position, and later can see why Z-index is for the picture stack emissions, here for 1,hover there is 2 (the effect is the bottom picture first display) */#container img: Hover{ z-index: ; -webkit-transform: Rotate (0deg) ; -webkit-transform: Scale (1.5) ; -ms-transform: Rotate (0deg) ; -ms-transform: Scale (1.5) ; transform: Rotate (0deg) ; Transform: Scale (1.5) ; Border: 5px solid #eee ; Box-shadow: ten px px , Rgba (0, 0 , 0,. 5) ;}/* This piece is to let the picture under the Hvoer the graphic transformation, the level display and enlarges 1.5 times times; Transform can also be abbreviated: eg:transform:rotate (90DEG) scale (1); *//* These subclasses are all to locate the initial position of the image and the rotation angle of */. Position_pic1{top : 100 px ; left : 5 px ; -webkit-transform : rotate (5 deg) ; -ms-transform : rotate (5 deg) ; transform : rotate (5 deg) ; .position_pic2 {top : 200 px ; left : px ; -webkit-transform : rotate (-12 deg) ; -ms-transform : rotate (-12 deg) ; transform : rotate (-12 deg) ; .position_pic3 {top : 20 px ; left : px ; -webkit-transform : rotate (-10 deg) ; -ms-transform : rotate (-10 deg) ; transform : rotate (-10 deg) ; .position_pic4 {top : 400 px ; left : 0 ; -webkit-transform : rotate (45 deg) ; -ms-transform : rotate (45 deg) ; transform : rotate (45 deg) ; .position_pic5 {top : 400 px ; left : px ; -webkit-transform : rotate (-5 deg) ; -ms-transform : rotate (-5 deg) ; transform : rotate (-5 deg) ; .position_pic6 {top : 500 px ; right : px ; -webkit-transform : rotate (-30 deg) ; -ms-transform : rotate (-30 deg) ; transform : rotate (-30 deg) ; .position_pic7 {top : 600 px ; left : px ; -webkit-transform : rotate (5 deg) ; -ms-transform : rotate (5 deg) ; transform : rotate (5 deg) ; .position_pic8 { top: px; Right : px; -webkit-transform: rotate (deg); -ms-transform: rotate (deg); transform: rotate (deg); }
Other
- CSS prefix is complete with the plugin "autoprefix" solution;
- CSS layout is to use the plugin "CSS comb" solution;
- Test browser Firefox 38/chrome 42
Pure CSS3 realization Picture Wall