zoukankan      html  css  js  c++  java
  • lesscss的使用

    1,在准备编写HTML文件时

    引入less.js或者<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script>

    2,目标CSS必须从外部引入,并且rel="stylesheet/less"

    例如:<link rel="stylesheet/less" href="new_file.css" />

    3,完整demo代码

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
            <link rel="stylesheet/less" href="new_file.css" />
            <link rel="import" href="new_file.html" />
            <script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script>
        </head>
        <body>
            
            <div class="top">
                <div class="circle">
                    <em></em>
                </div>
                <div class="rectangle">
                    <p></p>
                    <p></p>
                    <p></p>
                </div>
            </div>    
    
        </body>    
    
    </html>

    css代码如下:

    @blue:#28757D;
    @bg1:#A3B225;
    @bg2:#EA822D;
    @bg3:#40B0B1;
    @height:200px;
    .height(@height){
    	height: @height;
    }
    .border{
    	border: 1px solid @blue;
    	border-radius: 50%;
    }
    body,div,p,html{
    	padding: 0;
    	margin: 0;
    }
    .top{
    	 100%;
    	.height(@height);
    	position: relative;
    	.circle{
    		 60%;
    		.height(@height);
    		background: @blue;
    		margin: 0 auto;
    		.border;
    		em{
    			.border;
    			display: block;
    			margin: 20px;
    			 79%;
    			background: #FFFFFF;
    			.height(156px);
    		}
    	}
    	.rectangle{
    	 90%;
    	.height(80px);
    	clear: both;
    	position: absolute;
    	left: 5%;
    	top: 122px;
    	p{
    		height: 100%;
    		 33%;
    		float: left;
    	}
    	p:nth-child(1){
    		background: @bg1;
    	}
    	p:nth-child(2){
    		background: @bg2;
    	}
    	p:nth-child(3){
    		background: @bg3;
    	}
    }
    
    }
    

      iPhone4下效果呈现:

    官方链接:http://lesscss.org/

  • 相关阅读:
    Apachebench压力测试
    nodejs调试方法
    chrome 内存泄漏如何定位
    nodejs模块路径alias
    云计算基本概念IaaS,PaaS,SaaS和Serverless
    单点登录sso
    彻底删除mysql服务
    Java-Tomcat for Mac配置
    访问日志不记录静态文件 访问日志切割 静态元素过期时间
    Mac eclipse 连接安卓手机调试 adb
  • 原文地址:https://www.cnblogs.com/yuanyuan0809/p/5312245.html
Copyright © 2011-2022 走看看