Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the function of picture rotation with html5+div+css+js

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use html5+div+css+js to realize the image carousel function", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use html5+div+css+js to realize the picture carousel function"!

1. image tag

label

Labels used to display pictures. Its Src attribute is used to set the image source. In fact, you can also set width directly to set the width of the image, and set height to refer to the height of the image. It is worth noting that once the width of the image is set, the height of the image will automatically scale according to the image scale.

2. script tag

marker

Here we begin to write js code, which is used to control the logic of html tags on web pages, commonly known as DOM control. Mark of comment//single line comment/*... */multiline comment

2.1 logic

There's a logic control for picture switching, which is the change in n variables.

n++ means n=n+1 to switch picture names

2.2 dom control

document.getElementById("value corresponding to ID of tag in html") Returns a corresponding tag object.

innerHTML represents all html code inside a container.

3. Symbol-html correspondence

Symbol correspondence.

Spaces correspond to 20% of urls

4. summary

1. Learn to download pictures and make pictures

2, write js, it is best to learn zero-based VB tutorial, if there is no experience, then write according to

3. Write more and practice

4. setInterval to do timer, parameter 1 is a function, parameter 2 is time (milliseconds)

5. function(){ } This is an anonymous function that can be called directly

Material:

Source Code:

index.html file

Home-Liu Jinyu Programming Liu Jinyu Programming

main.css file

body{ margin:0;}.logo{ color:white; font-weight: bolder; padding:10px; font-size: 20px; background-color:#9ACD32;}#pics img{ width: 100%;} At this point, I believe that everyone has a deeper understanding of "how to use html5+div+css+js to realize the image carousel function." You may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report