css技巧

1. :root定义全局样式

<div class="app">
  
</div>
---------------
:root {
  --heer--background:skyblue;
}
.app{
  width:200px;
  height:200px;
  background:var(--heer--background);
}

2.attr()获取被选取的元素值

<div id="app">
  <p data="qwe">
    def
  </p>
</div>
------------------
[data]::before{
  content:attr(data);
}
posted @ 2022-10-13 16:19  禾耳  阅读(26)  评论(0)    收藏  举报