初识less
HTML文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>01-初识less.html</title>
<!--直接在html文件中书写less代码-->
<!--
<style type="text/less">
*{
margin: 0;
padding: 0;
}
.center{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.father{
width: 400px;
height: 400px;
background: brown;
.center;
.son{
width: 200px;
height: 200px;
background: skyblue;
.center;
}
}
</style>
-->
<!--从外部引入less文件-->
<link rel="stylesheet/less" href="css/index.less">
<script src="js/less.js"></script>
</head>
<body>
<div class="father">
<div class="son"></div>
</div>
</body>
</html>
less代码
*{
margin: 0;
padding: 0;
}
.center{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.father{
width: 400px;
height: 400px;
background: orange;
.center;
.son{
width: 200px;
height: 200px;
background: springgreen;
.center;
}
}
作者:陈太浪
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。