lessc的使用

<template>

? <div id="app">

? ? <div class="box">

? ? ? <h1>歡迎使用less</h1>

? ? </div>

? ? <div class="box1">

? ? ? <div class="box2">

? ? ? ? <div class="box3"></div>

? ? ? </div>

? ? </div>

? ? <ul>

? ? ? <li v-for="(item, index) in 4" :key="index">{{ item }}</li>

? ? </ul>

? ? <div class="boxa">我是box1</div>

? ? <div class="boxb">我是box2</div>

? </div>

</template>

<script>

export default {

? name: "App",

};

</script>

<style lang='less'>

// less 可以使用變量 可以嵌套

*{

? ? padding: 0;margin: 0;

? }

? @red: red;

? @blue:blue;

? @green:green;

? @imgurl: "../assets/";

? @k:100px;

? //定義一個函數(shù);

? .test(@color:red,@size:14px){

? ? ? background: @color;

? ? ? font-size:@size;

? }

? .boxa{

? //? 不傳參,使用默認的;

? ? ? .test()

? }

? .boxb{

? //? 給函數(shù)傳參;

? ? ? .test(@color:orange,@size:30px)

? }

? ul{

? ? width: @k;

? ? height: @k;

? ? background: @blue;


? ? li:nth-of-type(1){

? ? ? width: @k - 20px;

? ? ? background: @red;

? ? }

? ? li:nth-of-type(2){

? ? ? width: @k + 20px;

? ? ? background: @green;

? ? }

? }


? .box1{

? ? width: @k*2;

? ? height: @k*2;

? ? background: @red;

? ? .box2{

? ? ? width: @k;

? ? height: @k;

? ? background: @blue;

? ? ? .box3{

? width: @k/2;

? ? height: @k/2;

? ? background: @green;

? ? ? }

? ? }

? }

? .box {

? ? width: 200px;

? ? height: 200px;

? ? border: 1px solid red;

? ? background: url("@{imgurl}logo.png") no-repeat;

? ? h1 {

? ? ? color: @red;

? ? }

? }

</style>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容