web前端全系列 教程
1839个小节阅读:2242.9k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
LESS允许使用 @ 符号定义变量。 变量分配使用冒号(:)完成。
LESS中声明变量的格式为“@变量名:变量值”
xxxxxxxxxx
@width: 1200px;
@height: 300px;
.container {
width: @width;
height: @height;
background-color: #f1f1f1;
}
选择器的名字也可以使用变量声明
xxxxxxxxxx
@my-selector: banner;
.@{my-selector} {
font-weight: bold;
line-height: 40px;
margin: 0 auto;
}
xxxxxxxxxx
@images: "../img";
body {
color: #444;
background: url("@{images}/hello.png");
}
xxxxxxxxxx
.container {
width: @width;
height: @height;
background-color: #f1f1f1;
}
@width: 1200px;
@height: 300px;
使用$prop语法可以很容易地将属性当作变量来处理。有时,这可以使您的代码更轻松
xxxxxxxxxx
.widget {
color: #efefef;
background-color: $color;
margin: 15px;
padding: $margin;
font-size: 30px;
left:$font-size;
}
实时效果反馈
1. 在Less中,声明变量的关键字是:
A $
B var
C let
D @
答案
1=>D