Pure CSS3 creates a photo album effect, which feels pretty good. I would like to share it with you. The most important thing is that it does not use a single line of js. This is the highlight.
Today I accidentally discovered that there is such an example in my computer. I feel that the effect is pretty good. I don’t remember when I downloaded it. I haven’t used w3cfuns for a long time. I miss the days of learning the front desk, so I would like to share it with you.
Rendering:
The effect is still very good. The most important thing is that no line of js is used. This is the highlight.
Look at the html file first:
The code is as follows:
<body> <p id="g all ery"> <h1 id="纯CSS-相册效果">纯CSS3相册效果</h1> <ul> <li> <span class="touch"><img src="/static/imghwm/default1.png" data-src="images/pic1.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" ></span> <p style=" display : block;"> <img src="/static/imghwm/default1.png" data-src="images/pic1.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" > </p> </li> <li> <span><img src="/static/imghwm/default1.png" data-src="images/pic2.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" ></span> <p> <img src="/static/imghwm/default1.png" data-src="images/pic2.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" > </p> </li> <li> <span><img src="/static/imghwm/default1.png" data-src="images/pic3.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" ></span> <p> <img src="/static/imghwm/default1.png" data-src="images/pic3.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" > </p> </li> <li> <span><img src="/static/imghwm/default1.png" data-src="images/pic4.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" ></span> <p> <img src="/static/imghwm/default1.png" data-src="images/pic4.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" > </p> </li> <li> <span><img src="/static/imghwm/default1.png" data-src="images/pic5.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" ></span> <p> <img src="/static/imghwm/default1.png" data-src="images/pic5.jpg" class="lazy" / alt="Code example for making a photo album with H5 and CSS3" > </p> </li> </ul> <p class=" clear fix"></p> </p> </body>
Describe briefly:
1. li in ul determines the number of photos
2. ul uses the style float:right, width:140px; to display it in the right area of the album
3. li's float: left , so that li can float to the left; the p of the large image is stored in li, position is absolute and will be positioned according to p#gallary. By default, only the first one is displayed 4. When the mouse moves over li, change the transparency of li span img and the display of li p to display the large image
The next step is the css file:
<style type="text/css"> body { font-family : "微软雅黑"; } #gallery { width: 700px; position: relative; margin : 20px auto 0; background-color : #000; min-height : 400px; padding : 20px; } /*标题*/ #gallery h1 { color: #fff; font-size : 2em; font-weight : bold; } #gallery ul { width: 140px; float: right; margin: 10px 0 20px; } #gallery ul li { float: left; margin: 20px 8px 0 0; } #gallery ul li span { display: block; position: relative; width: 60px; height: 80px; border: 1px solid #fff; -moz-border-radius: 4px; -webkit-border-radius: 4px; -ms-border-radius: 4px; -o-border-radius: 4px; border-radius: 4px; overflow : hidden; } #gallery ul li span img { position: relative; top : -200px; left: -100px; filter: alpha(opacity=30); opacity: 0.3; } #gallery ul li span.touch img, #gallery ul li :hover span img { opacity: 1; filter: alpha(opacity=100); } #gallery ul li:hover p { display: block; } #gallery ul li p img { width: 460px; height: 288px; } #gallery ul li p { display: none; position: absolute; top: 100px; left: 30px; border: 5px solid #fff; } .clearfix { clear: both; } </style>There are no complicated styles in css, so I won’t describe them here. In addition, I introduced a reset style css in html,
reset.css. You can also use your own reset style:
The code is as follows:html, body, p, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend{ margin: 0; padding: 0; font-size: 100%; border: 0; outline: 0; background: transparent; } ol, ul { list-style: none; } blockquote, q { quotes: none; } :focus { outline: 0; } table { border-collapse: collapse; border-spacing: 0; }[Related recommendations]
H5 code example for making QR code scanning and parsing
3.Detailed explanation of HTML5 local database instance
4.Teach you how to implement an H5 micro-scenario
5.Detailed explanation of H5’s custom attributes data-*
The above is the detailed content of Code example for making a photo album with H5 and CSS3. For more information, please follow other related articles on the PHP Chinese website!

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

The tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.

HTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee

H5 improves web page accessibility and SEO effects through semantic elements and ARIA attributes. 1. Use, etc. to organize the content structure and improve SEO. 2. ARIA attributes such as aria-label enhance accessibility, and assistive technology users can use web pages smoothly.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool