Optimize css with stylus

三世轮回 提交于 2020-01-05 05:55:35

问题


I have such css:

p{
    margin: .85em auto;
    line-height: 1.7;
    text-indent: 2em;
  }
  blockquote p {
      text-indent: 0;
  }

Is there any way to optimize that using stylus?

Just to do something like that:

      p{
        margin: .85em auto;
        line-height: 1.7;
        (not if blockquote) text-indent: 2em;
      }

HTML I am trying to apply that to

  <div class="entry">
     <p></p> //text-indent here
     <blockquote>
      <p></p> //no text-indent here
     </blockquote>
    </div>

回答1:


Stylus can't read the HTML to know if you have a blockquote wrapping the p tag. Even if your code works I don't see any advantage over the CSS you have. Maybe in plain CSS you can use :not pseudo-class to save one line of code:

p {
  margin: .85em auto;
  line-height: 1.7;
}

:not(blockquote) > p {
  text-indent: 2em;
}


来源:https://stackoverflow.com/questions/40352952/optimize-css-with-stylus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!