HTML
1 <body> 2 <!-- ul.sprite>li*5>s.s-icon+a{CSS Sprite} --> 3 <!-- 以上是Sublime Text快速拼写 --> 4 <ul class="sprite"> 5 <li><s class="s-icon"></s><a href="">CSS Sprite</a></li> 6 <li><s class="s-icon"></s><a href="">CSS Sprite</a></li> 7 <li><s class="s-icon"></s><a href="">CSS Sprite</a></li> 8 <li><s class="s-icon"></s><a href="">CSS Sprite</a></li> 9 <li><s class="s-icon"></s><a href="">CSS Sprite</a></li>10 <div class="clear"></div>11 </ul>12 </body>
CSS
1 <style> 2 body { background-color: #fc0; color:#333;} 3 * {margin:0; padding:0;} 4 ul,li {list-style: none;} 5 a { color:#f00; font-weight: bold; text-decoration: none;} 6 .sprite {margin:0 auto; width:1000px; padding-top: 50px;} 7 .sprite li {float:left; margin-left: 50px; text-align: center; cursor:pointer; } 8 .sprite li s { display: block; width:132px; height:112px; background:url(all.png) no-repeat; } 9 .clear { clear:both;}10 </style>
JS
1 <script src="http://code.jquery.com/jquery-latest.js"></script> 2 <script> 3 $(function () { 4 var iconH = $(".sprite").find("s").height(), 5 //找出存放图片的容器的高度; 6 triggerLi = $(".sprite").children("li"); 7 //找出每一个li,放到一个数组中; 8 //console.log(iconH); 9 //在控制台打印出容器的高度;10 triggerLi.each(function () {11 //遍历数组中的每一个li12 var $this = $(this),13 //声明变量赋值当前的li;14 $index = $this.index();15 //声明变量保存当前li的index值;16 //console.log($index);17 //在控制台打印出每一个li的index值;18 //console.log(iconH*$index);19 //得出每一个图片对应的position值;20 $this.children("s").css("background-position","0 -"+iconH*$index+"px");21 //利用js遍历出每一个s标签的背景图片;22 $this.hover(function() {23 //鼠标移入24 $this.children("s").css("background-position","-132px -"+iconH*$index+"px");25 }, function() {26 //鼠标移出27 $this.children("s").css("background-position","0 -"+iconH*$index+"px");28 });29 })30 })31 </script>
IMG (right click to save, rename all.png)
SHOW

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.


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

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft