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

Explanation on whether to choose paging or loading in interactive design

The author of this article @子木yoyo posted it on hi...

CSS Tutorial: CSS Attribute Media Type

One of the most important features of a style she...

Convert XHTML CSS pages to printer pages

In the past, creating a printer-friendly version ...

Example of how to embed H5 in WeChat applet webView

Preface WeChat Mini Programs provide new open cap...

Use scripts to package and upload Docker images with one click

The author has been working on a micro-frontend p...

JS realizes the effect of Baidu News navigation bar

This article shares the specific code of JS to ac...

MySQL intercepts the sql statement of the string function

1. left(name,4) intercepts the 4 characters on th...

Abbreviation of HTML DOCTYPE

If your DOCTYPE is as follows: Copy code The code ...

Detailed explanation of script debugging mechanism in bash

Run the script in debug mode You can run the enti...

Example of how to set WordPress pseudo-static in Nginx

Quoting Baidu's explanation of pseudo-static:...

Detailed explanation of how to use JavaScript paging component

The pagination component is a common component in...

How to configure MySQL scheduled tasks (EVENT events) in detail

Table of contents 1. What is an event? 2. Enable ...

Detailed explanation of javascript knowledge points

Table of contents 1. Basic Introduction to JavaSc...