This article will share with you the QQ space photo album display effect based on JavaScript, involving html\css layout thinking, floating positioning details, please refer to this article for the specific implementation code
Knowledge points: html/css layout thinking, detailed explanation of floating/positioning, large enterprise standards, code performance optimization, js mouse events, DOM operations, etc.
Source code:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Keywords" content="关键词一,关键词二"> <meta name="Description" content="网站描述内容"> <title>Document</title> <style type="text/css"> {margin:0px;padding:0px;}
/css style expression: attribute: value; height: 1.7m; px pixels*/
Main{width:1000px;/宽/ height:640px;/高/ /background:#cc99cc;背景颜色/ margin:30px auto 0px;} Main ul li{width:288px;height:180px; border:4px solid #fff;/粗细 风格 颜色边框/ list-style-type:none;/去掉前面的圆点/ float:left;/左浮动/ margin:10px 17px; box-shadow:5px 5px 10px #000; } .gray{width:100%; height:100%;background:rgba(0,0,0,0.6); position:fixed;/固定定位/ left:0px; top:0px; display:none;/隐藏/} .showImg{width:650px; height:406px; background:red; position:absolute;/绝对定位/ top:100px; left:400px; border:10px solid #fff; display:none;/隐藏/} .showImg img.but_l{position:absolute; top:170px; left:-70px;} .showImg img.but_r{position:absolute; top:170px; right:-70px;} </style> </head> <body> <p id="Main"> <ul> <li><img src="/static/imghwm/default1.png" data-src="images/s1.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s2.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s3.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s4.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s5.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s6.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s7.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s8.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> <li><img src="/static/imghwm/default1.png" data-src="images/s9.jpg" class="lazy" big/ alt="How to use javascript to realize QQ space photo album display" ></li> </ul> </p> <p class="gray"></p> <p class="showImg"> <img class="show_bimg lazy" src="/static/imghwm/default1.png" data-src="images/big1.jpg" / alt="How to use javascript to realize QQ space photo album display" > <img class="but_l lazy" src="/static/imghwm/default1.png" data-src="images/dirl.png" / alt="How to use javascript to realize QQ space photo album display" > <img class="but_r lazy" src="/static/imghwm/default1.png" data-src="images/dirr.png" / alt="How to use javascript to realize QQ space photo album display" > </p> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> var _index=0; var bImg=null; $("#Main ul li").click(function(){ _index=$(this).index();//获取序列号 //alert(_index); $(".gray").show();//显示 $(".showImg").show();//显示 bImg=$(this).find("img").attr("bigsrc"); //alert(bImg); $(".showImg img.show_bimg").attr("src",bImg); }); $(".gray").click(function(){ $(".gray").hide();//隐藏 $(".showImg").hide(); }); //点击右边切换按扭 $(".showImg img.but_r").click(function(){ _index++;// _index+1; if(_index>8){_index=8; alert("右边到头了");} bImg=$("#Main ul li").eq(_index).find("img").attr("bigsrc"); $(".showImg img.show_bimg").attr("src",bImg); }); //点击左边切换按扭 $(".showImg img.but_l").click(function(){ _index--; //_index-1; if(_index<0){_index=0;alert("左边到头了");} bImg=$("#Main ul li").eq(_index).find("img").attr("bigsrc"); $(".showImg img.show_bimg").attr("src",bImg); }); </script> </body> </html>
The above is what I compiled for everyone, I hope It will be helpful to everyone in the future.
Related articles:
How to develop AngularJS 2 applications using the VS Code editor
About SPA first screen loading optimization in Vue (Detailed tutorial)
About the usage of the pipe operator (|) in Angular
About modifying the selected text or code in the VS Code editor Color operations
The above is the detailed content of How to use javascript to realize QQ space photo album display. For more information, please follow other related articles on the PHP Chinese website!

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.


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

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software