Solve the problem that ElementUI custom CSS style does not take effect

Solve the problem that ElementUI custom CSS style does not take effect

For example, there is an input box

<el-input
        ref="mySearch"
        class="mySearch"
        size="small"
        placeholder="Please enter content"
        suffix-icon="el-icon-search"
        v-model="input1">
</el-input>

If no custom style is added, the input box will look like this

insert image description here

I hope so

insert image description here

Through the developer tools of Google Chrome, find the class name of the corresponding style.el .el-input__inner
But I found that the el-input tag in front of html was parsed into this, where mySearch was added by myself, so we can find the element of mySearch , and the sub-element class name that needs to be modified is .el-input__inner

insert image description here

insert image description here

If you select child elements through CSS selectors, you cannot apply it to the elements inside the child elements. The following uses stylus syntax. The following is an incorrect way of writing:

<style scoped lang="stylus" rel="stylessheet/stylus">
    .mySearch .el-input__inner
        border-radius 20px
</style>

How to make it work

Solution 1: You need to add a /deep/ in the middle to

<style scoped lang="stylus" rel="stylessheet/stylus">
    .mySearch /deep/ .el-input__inner
        border-radius 20px
</style>

Solution 2: Remove scoped . This method can achieve the desired effect but is not recommended!

In general, the reason why it does not work is that this scope causes the scope to not work on the internal sub-components. The final solution to the problem is to add /deep/ to make it work on the sub-components.

This is the end of this article about the solution to the problem of ElementUI custom CSS style not taking effect. For more relevant content about ElementUI style not taking effect, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Detailed steps to deploy lnmp under Docker

>>:  How to remove the underline of a hyperlink using three simple examples

Recommend

What is html file? How to open html file

HTML stands for Hypertext Markup Language. Nowada...

js to achieve waterfall flow layout (infinite loading)

This article example shares the specific code of ...

Vue uniapp realizes the segmenter effect

This article shares the specific code of vue unia...

About Docker security Docker-TLS encrypted communication issues

Table of contents 1. Security issues with Docker ...

A brief analysis of MySQL cardinality statistics

1. What is the cardinality? Cardinality refers to...

A brief talk about React Router's history

If you want to understand React Router, you shoul...

HTML optimization techniques you must know

To improve the performance of web pages, many dev...

How to manage cached pages in Vue

Table of contents Problem 1: Destruction 1. How t...

JavaScript file loading and blocking issues: performance optimization case study

Let me start with a question: When writing an HTM...

How to use JS code compiler Monaco

Preface My needs are syntax highlighting, functio...

Thumbnail hover effect implemented with CSS3

Achieve resultsImplementation Code html <heade...