Scss 定義內層class的簡單寫法


如果定義樣式的時候,內層樣式名稱和外層保持一致的話可以簡寫如下

如果一個樣式下有相關的其他樣式可以使用 &-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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM