Table of Contents
第一部分:HTML
第二部分:CSS3
Home Web Front-end HTML Tutorial CSS3制作漂亮的照片墙

CSS3制作漂亮的照片墙

Jun 06, 2016 am 09:32 AM

CSS3可以做动画大家肯定都是耳熟能详的了,但是大家有木有巧妙的利用这一个功能来制作一款漂亮的照片墙呢?

那么今天我们就利用CSS3动画这一特性来一起制作漂亮的照片墙吧!

photo

第一部分:HTML

这里我们首先放十张图片在页面上面。(有什么靓照尽管上来哦!)

<span style="color: #0000ff;"><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="content"</span><span style="color: #0000ff;">></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic1"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/1.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic2"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/2.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic3"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/3.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic4"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/4.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic5"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/5.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic6"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/6.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic7"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/7.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic8"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/8.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic9"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/9.jpg"</span> <span style="color: #0000ff;">/></span>
    <span style="color: #0000ff;"><span style="color: #800000;">img </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="pic10"</span><span style="color: #ff0000;"> src</span><span style="color: #0000ff;">="img/10.jpg"</span> <span style="color: #0000ff;">/></span>
 <span style="color: #0000ff;"></span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span></span>
Copy after login

 

第二部分:CSS3

这一部分就是我们这节的重点了,如上图所示照片的位置各不相同,我们肯定会用到CSS3一下的知识点:

  • CSS3的旋转 rotate
  • CSS3的缩放 scale
  • CSS3的阴影 box-shadow 

没错就是这些功能我们就可以做一个漂亮的照片墙了。来看看我们的代码吧,这里只展示部分代码了聪明的小伙伴肯定知道怎么做的!

<span style="color: #800000;">body</span>{<span style="color: #ff0000;">
    background</span>:<span style="color: #0000ff;"> url(../img/bg1.jpg) no-repeat top center fixed</span>;<span style="color: #ff0000;">
    background-size</span>:<span style="color: #0000ff;"> 100% auto</span>;
}<span style="color: #800000;">
.content</span>{<span style="color: #ff0000;">
    width</span>:<span style="color: #0000ff;"> 900px</span>;<span style="color: #ff0000;"> 
    height</span>:<span style="color: #0000ff;"> 1000px</span>;<span style="color: #ff0000;">
    overflow</span>:<span style="color: #0000ff;"> hidden</span>;<span style="color: #ff0000;"> 
    margin</span>:<span style="color: #0000ff;"> 100px auto</span>;<span style="color: #ff0000;"> 
    position</span>:<span style="color: #0000ff;"> relative</span>;
}<span style="color: #800000;">
img</span>{<span style="color: #ff0000;"> 
    z-index</span>:<span style="color: #0000ff;"> 1</span>;<span style="color: #ff0000;">
    width</span>:<span style="color: #0000ff;"> 20%</span>;<span style="color: #ff0000;">
    height</span>:<span style="color: #0000ff;"> auto</span>;<span style="color: #ff0000;">
    position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">
    padding</span>:<span style="color: #0000ff;"> 10px 10px 15px 10px</span>;<span style="color: #ff0000;">
    background</span>:<span style="color: #0000ff;"> #ffffff</span>;<span style="color: #ff0000;">
    border</span>:<span style="color: #0000ff;"> 1px solid #CCCCCC</span>;
    <span style="color: #008000;">/*</span><span style="color: #008000;"> 动画的时间 </span><span style="color: #008000;">*/</span><span style="color: #ff0000;">
    -moz-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;<span style="color: #ff0000;">
    -webkit-transition</span>:<span style="color: #0000ff;"> 0.5s</span>;<span style="color: #ff0000;">
    transition</span>:<span style="color: #0000ff;"> 0.5s</span>;
 }<span style="color: #800000;">
img:hover</span>{<span style="color: #ff0000;">
    z-index</span>:<span style="color: #0000ff;"> 2</span>;<span style="color: #ff0000;">
    transform</span>:<span style="color: #0000ff;"> scale(1.5)</span>;<span style="color: #ff0000;">
    -moz-transform</span>:<span style="color: #0000ff;"> scale(1.5) </span>;<span style="color: #ff0000;">
    -webkit-transform</span>:<span style="color: #0000ff;"> scale(1.5) </span>;<span style="color: #ff0000;">
    box-shadow</span>:<span style="color: #0000ff;"> -10px 10px 20px #000000</span>;<span style="color: #ff0000;">
    -moz-box-shadow</span>:<span style="color: #0000ff;"> -10px 10px 20px #000000</span>;<span style="color: #ff0000;">
    -webkit-box-shadow</span>:<span style="color: #0000ff;"> -10px 10px 20px #000000</span>;
}<span style="color: #800000;">
.pic1</span>{<span style="color: #ff0000;">
    left</span>:<span style="color: #0000ff;"> 100px</span>;<span style="color: #ff0000;">
    top</span>:<span style="color: #0000ff;"> 50px</span>;<span style="color: #ff0000;">
    -webkit-transform</span>:<span style="color: #0000ff;"> rotate(20deg)</span>;<span style="color: #ff0000;">
    -moz-transform</span>:<span style="color: #0000ff;"> rotate(20deg)</span>;<span style="color: #ff0000;">
    transform</span>:<span style="color: #0000ff;"> rotate(20deg)</span>;
}<span style="color: #800000;">
.pic2</span>{<span style="color: #ff0000;">
    left</span>:<span style="color: #0000ff;"> 280px</span>;<span style="color: #ff0000;">
    top</span>:<span style="color: #0000ff;"> 60px</span>;<span style="color: #ff0000;">
    -webkit-transform</span>:<span style="color: #0000ff;"> rotate(-10deg)</span>;<span style="color: #ff0000;">
    -moz-transform</span>:<span style="color: #0000ff;"> rotate(-10deg)</span>;<span style="color: #ff0000;">
    transform</span>:<span style="color: #0000ff;"> rotate(-10deg)</span>;
}
Copy after login
/*   下面的代码大同小异就不依依展示了    */
Copy after login
就是这么简单的代码就可以实现上图所示的效果了。小伙伴们有兴趣的自己动手尝试一下把自己的靓照放上去看看。
Copy after login

PS: CSS3还可以写出更多的精彩绚丽效果,小伙伴有兴趣可以深入的研究一下!

有需要Demo的小伙伴给我留言吧,这次不提供下载了!

也可以加入我的QQ群 在群文件下载吧!点击加入

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

How to implement adaptive layout of Y-axis position in web annotation? How to implement adaptive layout of Y-axis position in web annotation? Apr 04, 2025 pm 11:30 PM

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

See all articles