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

How to wrap HTML title attribute

When I was writing a program a few days ago, I wan...

React Native environment installation process

react-native installation process 1.npx react-nat...

Solve the problem of VScode configuration remote debugging Linux program

Let's take a look at the problem of VScode re...

Detailed explanation of simple html and css usage

I will use three days to complete the static page...

JavaScript to implement a simple clock

This article example shares the specific code for...

Teach you how to implement a react from html

What is React React is a simple javascript UI lib...

Tips on MySQL query cache

Table of contents Preface Introduction to QueryCa...

Configure selenium environment based on linux and implement operation

1. Using Selenium in Linux 1. Install Chrome Inst...

MYSQL local installation and problem solving

Preface This article is quite detailed and even a...

Correct modification steps for Docker's default network segment

background A colleague is working on his security...

WeChat applet canvas implements signature function

In the WeChat applet project, the development mod...

jQuery implements accordion effects

This article shares the specific code of jQuery t...