Importance of css stylesheet hierarchy

后端 未结 3 1769
南方客
南方客 2020-12-03 07:54

I\'ve done some Google searches and so far I haven\'t found anything that answers my question about CSS order or importance.

For example, inline overrides external.

3条回答
  •  借酒劲吻你
    2020-12-03 08:59

    For this case here is what you do

    #content input { width: 50%; }
    #content .long { width: 75%; }
    

    selecting an element with its ID will take precedence, hence you had that particular problem. adding the ID to your selection and being more specific will solve the problem

    for example :

    #content input.long { width: 75%; }
    

    is even more specific than

    #content .long { width: 75%; }
    

提交回复
热议问题