Transition modules in HTML and CSS
This time I will bring you the transition module in HTML and CSS. What are the precautions for the transition module in HTML and CSS? The following is a practical case, let’s take a look.
Pseudo-class selector of a tag
a tag
1. Through our observation, we found that a tag has a certain state
1.1Default state, Never visited
1.2 Visited status
1.3 Mouse long press status
1.4 Mouse hovering over a label status
2 .What is the pseudo-class selector of a tag?
The pseudo-class selector of a tag is specially used to modify the style of different states of a tag
3.Format
:link Modify the style in the state that has never been visited
:visited Modify the style in the visited state
:hover Modify the style in the state when the mouse is hovering over the a tag
:active Modify the style when the mouse is long-pressed
a:link{ color: tomato; } a:visited{ color: green; } a:hover{ color: orange; } a:active{ color: pink; }
4. Note that
4.1a The pseudo-class selector of the label can appear alone or together
4.2 If the pseudo-class selectors of the a tag appear together, there are strict order requirements
The order of writing must comply with the principle of love hate
4.3 If the default state style The style of the visited state is the same, then you can abbreviate
a{ // 简写格式 color: green; } a:hover{ color: orange; } a:active{ color: pink; }
Pseudo-class selector for a tag Exercise
1. It is best to write a pseudo-class selector for a tag in enterprise development Behind the label selector
2. In enterprise development, the attributes related to a label box are written in the label selector (display mode/width/height/padding/margin)
3. In enterprise development Everything related to the a tag text/background is written in the pseudo-class selector
ul li a{ width: 120px; height: 40px; display: inline-block; } ul li a:link{ background-color: pink; color: white; text-decoration: none; } ul li a:hover{ color: red; background-color: #ccc; } ul li a:active{ color: yellow; }
a tag pseudo-class selector practice
Transition module
p{ width: 100px; height: 50px; background-color: red; /*告诉系统哪个属性需要执行过渡效果*/ transition-property: width, background-color; /*告诉系统过渡效果持续的时长*/ transition-duration: 5s, 5s; /*transition-property: background-color;*/ /*transition-duration: 5s;*/ } *:hover这个伪类选择器除了可以用在a标签上, 还可以用在其它的任何标签上*/ p:hover{ width: 300px; background-color: blue; } ![过渡模块 ] (http://upload-images.jianshu.io/upload_images/1482909-de9fd4fa86de87cc.gif?imageMogr2/auto-orient/strip) ######1,过渡三要素 1.1必须要有属性发生变化 1.2必须告诉系统哪个属性需要执行过渡效果 1.3必须告诉系统过渡效果持续时长 ######2.注意点 当多个属性需要同时执行过渡效果时用逗号隔开即可 transition-property: width, background-color; transition-duration: 5s, 5s; ### 过渡模块-其它属性 > transition-delay: 2s; //告诉系统延迟多少秒之后才开始过渡动画 transition-timing-function: linear; //告诉系统过渡动画的运动的速度 ###### transition-timing-function: 有五个取值 linear, ease , ease-in , ease-out , ease-in-out  ### 过渡连写格式 >######1.过渡连写格式 transition: 过渡属性 过渡时长 运动速度 延迟时间; transition: background-color 5s linear 0s;>######2.过渡连写注意点 2.1和分开写一样, 如果想给多个属性添加过渡效果也是用逗号隔开即可 transition: width 5s linear 0s,background-color 5s linear 0s;
2.2 When writing continuously The last two parameters can be omitted, because as long as the first two parameters are written, the three elements of transition have been satisfied
transition: width 5s,background-color 5s,height 5s;
2.3 If there are multiple attributes of movement speed/delay time/duration are the same, then it can be abbreviated as:
transition:all 5s;
Writing transition routines>1.1 Don’t worry about the transition, write the basic interface first 1.2 Modify the attributes we think need to be modified 1.3 Go back and add a transition to the element whose attributes have been modified
. Elastic effect
<html> <head> <meta charset="UTF-8"> <title>91-过渡模块-弹性效果</title> <style> { margin: 0; padding: 0; } p{ height: 100px; background-color: red; margin-top: 100px; text-align: center; line-height: 100px; } p span{ font-size: 80px; /transition-property: margin;/ /transition-duration: 3s;*/ transition: margin 3s; } p:hover span{ margin: 0 20px; } </style> </head> <body> <p> <span>呼</span> <span>伦</span> <span>贝</span> <span>尔</span> <span>大</span> <span>草</span> <span>原</span> <span>儿</span> </p> </body> </html>
Accordion effect
<html> <head> <meta charset="UTF-8"> <title>92-过渡模块-手风琴效果</title> <style> { margin: 0; padding: 0; } ul{ width: 960px; height: 300px; margin: 100px auto; border: 1px solid #000; overflow: hidden; } ul li{ list-style: none; width: 160px; height: 300px; background-color: red; float: left; /border: 1px solid #000;/ /box-sizing: border-box;/ /transition-property: width;/ /transition-duration: 0.5s;*/ transition: width 0.5s; } ul:hover li{ width: 100px; //ul 被hover 所得li宽度都变成100px } ul li:hover{ width: 460px; //更具体,优先级更高 只有被hover 的li 才会变宽 } </style> </head> <body> <ul> <li> </li> <li> </li> <li> </li> <li> </li> <li> </li> <li> </li> </ul> </body> </html>
I believe you have seen it You have mastered the method in the case of this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
The layout method of web pages: clearing floats
The above is the detailed content of Transition modules in HTML and CSS. For more information, please follow other related articles on the PHP Chinese website!

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics











Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

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

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.

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

When developing websites using CraftCMS, you often encounter resource file caching problems, especially when you frequently update CSS and JavaScript files, old versions of files may still be cached by the browser, causing users to not see the latest changes in time. This problem not only affects the user experience, but also increases the difficulty of development and debugging. Recently, I encountered similar troubles in my project, and after some exploration, I found the plugin wiejeben/craft-laravel-mix, which perfectly solved my caching problem.
