How to select all child elements and add styles to them in CSS

How to select all child elements and add styles to them in CSS

method:

Take less in the actual project as an example:

.lk-toolbar {
    .el-input {
        width: 169px;
        margin-right: 10px;
    }
    > * {
        margin-bottom: 20px;
    }
}

The above code successfully implements the margin-bottom: 20px of all sub-elements under .lk-toolbar

This avoids the idiotic task of listing all possible sub-element types:

.lk-toolbar {
    .el-input {
        width: 169px;
        margin-right: 10px;
        margin-bottom: 20px;
    }
    .el-button, .el-date-editor {
        margin-bottom: 20px;
    }
}

Application scenarios (effects):

Insights (nonsense):

At first I wondered if there was such a selector in CSS to select all child elements. Later I looked at the documentation and found that although there was no such selector, the most basic method has been told to you, and the rest depends on your own luck (see if you can use it flexibly!)

Tutorial OS: "The methods are all here. It's up to you whether you can use them or not."

This concludes this article on how to select all child elements and add styles with CSS. For more information on adding styles to child elements with CSS, please search previous articles on 123WORDPRESS.COM or continue browsing the related articles below. We hope that everyone will support 123WORDPRESS.COM in the future!

<<:  Some common properties of CSS

>>:  Implementation code for adding links to FLASH through HTML (div layer)

Recommend

Javascript to achieve drumming effect

This article shares the specific code of Javascri...

Detailed explanation of the use and precautions of crontab under Linux

Crontab is a command used to set up periodic exec...

MySQL 5.6.28 installation and configuration tutorial under Linux (Ubuntu)

mysql5.6.28 installation and configuration method...

JS+Canvas draws a lucky draw wheel

This article shares the specific code of JS+Canva...

Some references about colors in HTML

In HTML, colors are represented in two ways. One i...

Solution to the conflict between nginx and backend port

question: When developing the Alice management sy...

JavaScript event capture bubbling and capture details

Table of contents 1. Event Flow 1. Concept 2. DOM...

Linux kernel device driver kernel time management notes

/****************** * Linux kernel time managemen...

CSS3 animation to achieve the effect of streamer button

In the process of learning CSS3, I found that man...

Tutorial on installing MYSQL8.0 on Alibaba Cloud ESC

Open the connection tool. I use MobaXterm_Persona...

Detailed explanation of Axios asynchronous communication in Vue

1. First, we create a .json file for interactive ...

Tutorial on installing the unpacked version of mysql5.7 on CentOS 7

1. Unzip the mysql compressed package to the /usr...

CSS3 mobile vw+rem method to achieve responsive layout without relying on JS

1. Introduction (1) Introduction to vw/vh Before ...