Giter Site home page Giter Site logo

Comments (1)

zanjs avatar zanjs commented on May 11, 2024

有其他优先级更高的样式覆盖了这个样式

  1. 内联样式表的权值最高 1000;

  2. ID 选择器的权值为 100

  3. Class 类选择器的权值为 10

  4. HTML 标签选择器的权值为 1

5 继承样式的权值为0.1(某些论文提出,但毫无疑问它的权值是最低的)

css优先级:!important > 内联 > id选择器 > 类选择器 > 元素选择器

选择器都有一个权值,权值越大优先级越高。

假设内联的权值为 1000id100 ,类 10 ,元素 1

.nav-wrap ul li 的权值为 10+1+1=12

.line-active 的权值为 10

所以 .nav-wrap ul li.line-active 有更高的优先级

from awesome-frontend-interview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.