What types of css3 attribute selectors include
css3 attribute selector includes 3 types: 1. "E[att^=value]" selector, selects the tag named E, and the tag defines the att attribute, and the attribute value includes the prefix of value Substring; 2. "E[att$=value]" selector; 3. "E[att*=value]" selector.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Attribute selector can select elements based on their attributes and attribute values. Three new attribute selectors have been added to CSS3: E[att^=value]
, E[att$=value]
and E[att*=value]
, we will introduce it in detail below.
<span style="font-size: 18px;"><strong>E[att^=value]</strong></span>
Attribute selector
E[att^=value]
The attribute selector refers to selecting the tag named E, and the tag defines the att attribute, and the att attribute value contains the substring prefixed with value. It should be noted that E can be omitted. If omitted, it means that any element that meets the condition can be matched. For example, div[id^=section]
indicates that the match contains the id attribute, and the id attribute value is a div element starting with the "section" string.
The following uses a case to demonstrate the usage of the E[att^=value]
attribute selector, as shown below.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>E[att^=value]属性选择器的应用</title> <style type="text/css"> p[id^="one"]{ color:pink; font-family: "微软雅黑"; font-size: 20px; } </style> </head> <body> <p id="one">为了看日出,我常常早起。那时天还没有大亮,周围非常清静,船上只有机器的响声。</p> <p id="two">天空还是一片浅蓝,颜色很浅。转眼间天边出现了一道红霞,慢慢地在扩大它的范围,加强它的亮光。我知道太阳要从天边升起来了,便目不转睛地望着那里。</p> <p id="one1">果然过了一会儿,在那个地方出现了太阳的小半边脸,红是真红,却没有亮光。这个太阳好像负着重荷似地一步一步、慢慢地努力上升,到了最后,终于冲破了云霞,完全跳出了海面,颜色红得非常可爱。一刹那间,这个深红的圆东西,忽然发出了夺目的亮光,射得人眼睛发痛,它旁边的云朵也突然有了光彩。</p> <p id="two1">有时太阳走进了云堆中,它的光线却从云里射下来,直射到水面上。这时候要分辨出哪里是水,哪里是天,倒也不容易,因为我就只看见一片灿烂的亮光。</p> </body> </html>
In the above code, the [att^=value]
selector "p[id^="one"]
" is used. As long as the id attribute value in the p element starts with the "one" string, it will be selected, thus presenting a special text effect.
<span style="max-width:90%"><strong>E[att$=value]</strong></span>
Attribute Selector
E[att$=value]
The attribute selector refers to selecting the tag named E, and the tag defines the att attribute, and the att attribute value contains the suffix substring of value. Like the E[att^=value]
selector, the E element can be omitted. If omitted, it means that any element that meets the condition can be matched. For example, div[id$=section]
indicates that the match contains the id attribute, and the id attribute value is the div element ending with the "section" string.
The following uses a case to demonstrate the usage of the E[att$=value]
attribute selector, as shown below.
<!Doctype html> <html> <head> <meta charset="utf-8"> <title>E[att$=value] 属性选择器的应用</title> <style type="text/css"> p[id$="main"]{ color: #0cf; font-family: "宋体"; font-size: 20px; } </style> </head> <body> <p id="old1">盼望着,盼望着,东风来了,春天的脚步近了。</p> <p id="old2">小草偷偷地从土里钻出来,嫩嫩的,绿绿的。园子里,田野里,瞧去,一大片一大片满是的。坐着,躺着,打两个滚,踢几脚球,赛几趟跑,捉几回迷藏。风轻悄悄的,草绵软软的。</p> <p id="oldmain">桃树、杏树、梨树,你不让我,我不让你,都开满了花赶趟儿。红的像火,粉的像霞,白的像雪。花里带着甜味,闭了眼,树上仿佛已经满是桃儿、杏儿、梨儿!花下成千成百的蜜蜂嗡嗡地闹着……</p> <p id="newmain">“吹面不寒杨柳风”,不错的,像母亲的手抚摸着你。风里带来些新翻的泥土的气息,混着青草味,还有各种花的香,都在微微润湿的空气里酝酿。鸟儿将窠巢安在繁花嫩叶当中,高兴起来了……</p> </body> </html>
In the above code, the [att$=value]
selector "p[id$="main"]
" is used. As long as the id attribute value in the p element ends with the "main" string, it will be selected, thus presenting a special text effect.
<span style="max-width:90%"><strong>E[att*=value]</strong></span>
Attribute Selector
E[att*=value]
The selector is used to select the tag named E, and the tag defines the att attribute, and the att attribute value contains the value substring . This selector is the same as the previous two selectors. The E element can also be omitted. If omitted, it means that any element that meets the condition can be matched. For example, div[id*=section]
means matching div elements that contain the id attribute and the id attribute value contains the "section" string.
The following uses a case to demonstrate the usage of the E[att*=value]
attribute selector, as shown below.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>E[att*=value]属性选择器的使用</title> <style type="text/css"> p[id*="demo"]{ color:#0ca; font-family: "宋体"; font-size: 20px; } </style> </head> <body> <p id="demo1">我们消受得秦淮河上的灯影,当四月犹皎的仲夏之夜。 </p> <p id="main1">在茶店里吃了一盘豆腐干丝,两个烧饼之后,以至歪的脚步踅上夫子庙前停泊着的画访,就懒洋洋地躺到藤椅上去了。好郁蒸的江南,傍也还是热的。"快开船罢!"桨声响了。</p> <p id="newdemo">小的灯舫初次在河中荡漾;于我,情景是颇朦胧,滋味是怪羞涩的。我要错认它作七里的山塘;可是,河房里明窗洞启,映着玲珑入画的栏干,顿然省得身在何处了……</p> <p id="olddemo">又早是夕阳西下,河上妆成一抹胭脂的薄媚。是被青溪的姊妹们所薰染的吗?还是匀得她们脸上的残脂呢?寂寂的河水,随双桨打它,终没言语。密匝匝的绣恨逐老去的年华,已都如蜜饧似的融在流波的心窝里、连呜咽也将嫌它多事,更哪里论到哀嘶……</p> </body> </html>
In the above code, the [att*=value]
selector "p[id*="demo"]
" is used. As long as the id attribute value in the p element contains the "demo" string, it will be selected, thus presenting a special text effect.
(Learning video sharing: css video tutorial)
The above is the detailed content of What types of css3 attribute selectors include. 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

AI Hentai Generator
Generate AI Hentai for free.

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

How to achieve wave effect with pure CSS3? This article will introduce to you how to use SVG and CSS animation to create wave effects. I hope it will be helpful to you!

This article will show you how to use CSS to easily realize various weird-shaped buttons that appear frequently. I hope it will be helpful to you!

Two methods: 1. Using the display attribute, just add the "display:none;" style to the element. 2. Use the position and top attributes to set the absolute positioning of the element to hide the element. Just add the "position:absolute;top:-9999px;" style to the element.

In CSS, you can use the border-image attribute to achieve a lace border. The border-image attribute can use images to create borders, that is, add a background image to the border. You only need to specify the background image as a lace style; the syntax "border-image: url (image path) offsets the image border width inward. Whether outset is repeated;".

How to create text carousel and image carousel? The first thing everyone thinks of is whether to use js. In fact, text carousel and image carousel can also be realized using pure CSS. Let’s take a look at the implementation method. I hope it will be helpful to everyone!

Adaptive layout, also known as "responsive layout", refers to a web page layout that can automatically recognize the screen width and make corresponding adjustments; such a web page can be compatible with multiple different terminals instead of making a specific version for each terminal. . Adaptive layout was born to solve the problem of mobile web browsing, and can provide a good user experience for users using different terminals.

Title: Elegantly use jQuery to find elements whose name attribute is not undefined. When developing web pages, we often need to use jQuery to operate DOM elements, and we often need to find elements based on specific conditions. Sometimes we need to find elements with specific attributes, such as finding elements whose name attribute is not undefined. This article will introduce how to elegantly use jQuery to achieve this function, and attach specific code examples. First, let's take a look at how to use jQ

Title: Practical Tips: Use jQuery to quickly modify the attribute values of table rows. In web development, we often encounter situations where we need to dynamically modify the attribute values of table rows through JavaScript. Using jQuery, you can quickly implement this function while writing concise and efficient code. Some practical tips will be shared below to make it easier to operate and modify the attribute values of table rows in actual projects. 1. Get the attribute value of the table row and use jQuery to modify the attribute of the table row.
