美文网首页
Vue中scss定义内层class的巧妙使用

Vue中scss定义内层class的巧妙使用

作者: leslie1943 | 来源:发表于2020-07-06 14:49 被阅读0次

简写形式

如果一个样式下有相关的其他样式可以使用 &-xxx 来简写

<template>
<div class="test-container">
  <div class="test-container-header">header</div>
  <div class="test-container-body">body</div>
  <div class="test-container-footer">footer</div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss">
.test-container {
  background: pink;
  height: 200px;
  &-header {
    font-size: 24px;
    color: #67c23a;
  }
  &-body {
    font-size: 24px;
    color: #f56c6c;
  }
  &-footer {
    font-size: 24px;
    color: #909399;
  }
}
</style>

相关文章

网友评论

      本文标题:Vue中scss定义内层class的巧妙使用

      本文链接:https://www.haomeiwen.com/subject/fhgwqktx.html