Example code of setting label style using CSS selector

Example code of setting label style using CSS selector

CSS Selectors

Setting style on the html tag can set attributes for the tag:

<div style="background-color: #2459a2;height: 48px;">Ahhh</div>

We can also set the selector in the <head> tag, so that each style only needs to be written once

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        <!--Write the selector here-->
    </style>
</head>

There are many specific selectors:

1. Copy style by id

#i1{
    background-color: #2459a2;
    height: 48px;
}

The tags in the body are used like this: But you can't write multiple ids, so you still can't use them multiple times.

    <div id="i1"></div>
    <div id="i1"></div>But you cannot write multiple ids (not standard)

2. Copy by class:

/*class selector: Use class=c1 to copy this style, while avoiding the defect that the id must be unified*/
.c1{
    background-color: #2459a2;
    height: 60px;
}

When using:

 <div class="c1">1251251</div> can be written in multiples <div class="c1">1251253</div> can be written in multiples

3. Tag selector: Change a certain tag to this style:

Tag selector: Change all div tags to black background and white text

div{
    background-color: black;
    color: white;
}

4. Level selector: space in the middle

Hierarchical selector: Change the div tag in the span tag to this style

  span div{
            background-color: black;
            color: white;
        }
        Layer: Set the div in c1 and c2 to this style. c1 .c2 div{
            background-color: black;
            color: white;
        }

5. Combined selector: comma in the middle

    <style>
        Combination selector: # or . can realize the combination #i1, #i2, #i3{
            background-color: black;
            color: white;
        }
        .c5,.c6,.c7{
            background-color: black;
            color: white;
        }
    </style>

6. Attribute selector:

    <style>        
        /*Attribute selector: set type='text' to this style*/
        input[type='text']{
            width: 100px;
            height: 200px;
        }
        Set the custom n value s1 label to this style input[n='s1']{
            width: 100px;
            height: 200px;
        }
    </style>

Summarize

The above is the example code of the CSS selector setting label style introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  Do you know how to use the flash wmode attribute in web pages?

>>:  MySQL implements string concatenation, interception, replacement, and position search operations

Recommend

How to handle concurrent updates of MySQL data

Will UPDATE lock? Will the SQL statement be locke...

MySQL Null can cause 5 problems (all fatal)

Table of contents 1. Count data is lost Solution ...

HTML table markup tutorial (5): light border color attribute BORDERCOLORLIGHT

In a table, you can define the color of the upper...

Initial settings after installing Ubuntu 16 in the development environment

The office needs Ubuntu system as the Linux devel...

How to delete a property of an object in JavaScript

1. delete delete is the only real way to remove a...

What are the usages of limit in MySQL (recommended)

SELECT * FROM table name limit m,n; SELECT * FROM...

Common commands for mysql authorization, startup, and service startup

1. Four startup methods: 1.mysqld Start mysql ser...

Summary of Linux ps and pstree command knowledge points

The ps command in Linux is the abbreviation of Pr...

Build a WebRTC video chat in 5 minutes

In the previous article, I introduced the detaile...

Windows Server 2016 Quick Start Guide to Deploy Remote Desktop Services

Now 2016 server supports multi-site https service...

Steps to install MySQL 5.7.10 on Windows server 2008 r2

Install using the MSI installation package Downlo...

Vue routing relative path jump method

Table of contents Vue routing relative path jump ...

Docker installation tomcat dubbo-admin instance skills

1. Download the tomcat image docker pull tomcat:8...