This article mainly introduces the specific steps of making a beautiful photo wall with CSS3 in detail. It has certain reference value. Interested friends can refer to it.
The examples in this article are to share with you the use of CSS3 The detailed steps for creating an animated photo wall are for your reference. The specific content is as follows
The first effect:
The Html code is as follows:
<body> <h2>照片墙制作</h2> <p class="container"> <img class="img1" src="img/img (1).jpg" height="150" width="150" alt=""> <img class="img2" src="img/img (2).jpg" height="160" width="200" alt=""> <img class="img3" src="img/img (3).jpg" height="170" width="200" alt=""> <img class="img4" src="img/img (4).jpg" height="240" width="200" alt=""> <img class="img5" src="img/img (5).jpg" height="300" width="300" alt=""> </p> </body>
The CSS code is as follows:
<style> * {margin:0; padding:0;} body { background-color: #eee; padding-top: 50px;} h2 { text-align: center;} .container { position: relative; width:1000px; height:700px; margin:0px auto; } img { position: absolute; top:50px; left:100px; cursor: pointer; padding:10px 10px 25px; background-color: #fff; border:1px solid #ddd; transition:0.5s; box-shadow: 3px 3px 3px #ccc; } .img1 { left:40px; top:20px; transform:rotate(30deg); z-index: 1;} .img2 { left:156px; top:156px; transform:rotate(-30deg); z-index: 1;} .img3 { left:381px; top:60px; transform:rotate(30deg); z-index: 1;} .img4 { left:458px; top:256px; transform:rotate(30deg); z-index: 1;} .img5 { left:684px; top:110px; transform:rotate(-40deg); z-index: 1;} img:hover { transform:rotate(0deg); transform:scale(1.5); box-shadow: 6px 6px 6px #656565; z-index: 2;} </style>
Effect picture:
The second implementation effect:
Part One: HTML
Here we first put ten pictures on the page. (If you have any beautiful photos, please post them!)
<p class="content"> <img class="pic1" src="img/1.jpg" /> <img class="pic2" src="img/2.jpg" /> <img class="pic3" src="img/3.jpg" /> <img class="pic4" src="img/4.jpg" /> <img class="pic5" src="img/5.jpg" /> <img class="pic6" src="img/6.jpg" /> <img class="pic7" src="img/7.jpg" /> <img class="pic8" src="img/8.jpg" /> <img class="pic9" src="img/9.jpg" /> <img class="pic10" src="img/10.jpg" /> </p>
Part 2: CSS3
This part is the focus of our section, As shown in the picture above, the positions of the photos are different. We will definitely use the following knowledge points of CSS3:
CSS3 rotation rotate
CSS3 scaling
CSS3 shadow box- shadow
Yes, with these functions we can make a beautiful photo wall. Let’s take a look at our code. Only part of the code is shown here. Smart friends must know how to do it!
body{ background: url(../img/bg1.jpg) no-repeat top center fixed; background-size: 100% auto; } .content{ width: 900px; height: 1000px; overflow: hidden; margin: 100px auto; position: relative; } img{ z-index: 1; width: 20%; height: auto; position: absolute; padding: 10px 10px 15px 10px; background: #ffffff; border: 1px solid #CCCCCC; /* 动画的时间 */ -moz-transition: 0.5s; -webkit-transition: 0.5s; transition: 0.5s; } img:hover{ z-index: 2; transform: scale(1.5); -moz-transform: scale(1.5) ; -webkit-transform: scale(1.5) ; box-shadow: -10px 10px 20px #000000; -moz-box-shadow: -10px 10px 20px #000000; -webkit-box-shadow: -10px 10px 20px #000000; } .pic1{ left: 100px; top: 50px; -webkit-transform: rotate(20deg); -moz-transform: rotate(20deg); transform: rotate(20deg); } .pic2{ left: 280px; top: 60px; -webkit-transform: rotate(-10deg); -moz-transform: rotate(-10deg); transform: rotate(-10deg); } /* 下面的代码大同小异就不依依展示了 */
Such a simple code can achieve the effect shown in the picture above. Friends, if you are interested, try it yourself and post your beautiful photos to see.
PS: CSS3 can also create more wonderful and gorgeous effects. If you are interested, you can study it in depth!
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
How to implement single-line and multi-line text overflow display ellipses using CSS
How to implement css icons Align with text
The above is the detailed content of Use CSS3 to create special effects for photo walls. For more information, please follow other related articles on the PHP Chinese website!