There are three types of attribute value regular matching selectors:
These three attribute selectors match characters, not words. The angle symbol Using these selectors, pure CSS can create very cool functions. Displays a small icon for the hyperlink and a graphic of the file type The [href] {padding-left: 18px;} /* Link address*/ [href^="https"], [href^="//"] { background: url("./images/link.png") no-repeat left; } /* Anchor link in web page */ [href^="#"] background: url("./images/anchor.png") no-repeat left; } /* Mobile phone and email */ [href^="tel:"] background: url("./images/tel.png") no-repeat left; } [href^="mailto:"] background: url("./images/e-mail.png") no-repeat left; } Effect By using /* Point to the PDF file */ [href$=".pdf"] background: url("./images/pdf.png") no-repeat left; } /* Download the zip file */ [href$=".zip"] { background: url("./images/zip.png") no-repeat left; } /* Image link*/ [href$=".png"], [href$=".gif"], [href$=".jpg"], [href$=".jpeg"], [href$=".webp"] background: url("./images/image.png") no-repeat left; } The effect is as follows CSS attribute selector search filtering technology We can use attribute selectors to help us achieve search filtering effects, such as address books and city lists. This has high performance and requires less code. The HTML structure is as follows: <input type="search" id="input" placeholder="Enter the city name or pinyin" /> <ul> <li data-search="Chongqing Citychongqing">Chongqing City</li> <li data-search="Harbin Cityhaerbin">Harbin City</li> <li data-search="Changchun Citychangchun">Changchun City</li> <li data-search="Changsha Citychangsha">Changsha City</li> <li data-search="沪shanghai">Shanghai</li> <li data-search="Hangzhou Cityhangzhou">Hangzhou City</li> </ul> At this point, when we enter content in the input box, we can achieve the search and matching effect by dynamically creating a CSS code based on the input content, without having to write code for matching verification ourselves. var eleStyle = document.createElement('style'); document.head.appendChild(eleStyle); // Text input box input.addEventListener('input', function() { var value = this.value.trim(); eleStyle.innerHTML = value ? '[data-search]:not([data-search*="' + value +'"]) { display: none; } ' : ''; }); This concludes this article on how to cleverly use CSS attribute value regular matching selectors (tips). For more relevant CSS attribute value regular matching content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Getting Started with MySQL - Concepts
>>: HTML+css to create a simple progress bar
Based on theories such as Saussure's philosop...
The process of installing MySQL database and conf...
Table of contents Component Communication Introdu...
MySQL supports hash and btree indexes. InnoDB and...
This article shares the specific code of Vue to i...
Table of contents 1. Cause 2. Equipment Informati...
This article shares the specific code of Element-...
This tag is not part of HTML3.2 and only supports ...
1.1 Download the binary installation package wget...
The meaning of key_len In MySQL, you can use expl...
After installing Docker on the Linux server, Pull...
Preface I was recently reading about MySQL indexe...
•There are many selectors in CSS. What will happe...
In the MySQL database, after tables are associate...
Preface: In MySQL, views are probably one of the ...