html - Issues with CSS element priority.
漂亮男人
漂亮男人 2017-05-16 13:26:25
0
8
870
  <style>
    .Line li,.Line dt{float:left}
    .Float-R{float:right}
  </style>
  <p class="Line">
    <ul>
      <li>text1</li>
      <li>text2</li>
      <li class="Float-R">text3</li>
    </ul>
  </p>

My .Line and .Float-R are common styles
The global li here is left-aligned. I want the specified li to be on the right, without adding !important and using ## How can I achieve the result I want in the case of ##id?Or is there no solution?

漂亮男人
漂亮男人

reply all(8)
習慣沉默

CSS3 pseudo-class

仅有的幸福

nth-child() selector

滿天的星座

In a style, the later ones will overwrite the previous ones. You can add what you need at the back. If you specify li, you can select it through nth-child, or you can get the dom node through js and set the style style

过去多啦不再A梦

Change the second sentence to this
.Line li.Float-R{float:right}

phpcn_u1582

As for the original poster’s question, just change the second sentence to li.Float-R{float:right} and try to follow the priority rules.

巴扎黑

css priority is based on positioning accuracy
that is to say

.Line ul li.Float-R{
float:left;
}
p.Line ul li.Float-R{
float:right;//这里会覆盖上面的样式
}
某草草

Add more classes to increase priority

曾经蜡笔没有小新

.Float-R replaced with .Line li.Float-R

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!