初识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;
  }
}

posted @ 2020-05-13 22:05  陈太浪  阅读(125)  评论(0编辑  收藏  举报