码迷,mamicode.com
首页 > 其他好文 > 详细

less引用其他less文件

时间:2017-02-23 22:56:22      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:less引用其他less文件

示例

//radius.less
#header,#footer{
	-webkit-border-radius: 5px;
  	-moz-border-radius: 5px;
  	-ms-border-radius: 5px;
  	-o-border-radius: 5px;
  	border-radius: 5px;
}


//example6.less
@import "radius.less";

@the-border:1px;
@base-color:#111;
@red:#842210;

#header{
	color:(@base-color * 3);
	border-left:(@the-border*10);
	border-right:(@the-border * 2);
}

#footer{
	color:(@base-color + #003300);
	border-color:desaturate(@red,10%);
}


说明

@import "radius.less" 表示通过import引入一个名字叫radius的less文件


生成的csss文件(example6.css)

#header,
#footer {
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  -ms-border-radius: 5px;
  -o-border-radius: 5px;
  border-radius: 5px;
}
#header {
  color: #333333;
  border-left: 10px;
  border-right: 2px;
}
#footer {
  color: #114411;
  border-color: #7d2717;
}


在html文件中使用css(less6.html)

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>less6</title>
	<link rel="stylesheet" href="example6.css">
	<style>
		#header,#footer{
			width: 500px;
			height: 400px;
		}

		#header{
			border-style: solid;
		}

		#footer{
			border-style: solid;
			border-width: 1px;
		}
	</style>
</head>
<body>
	<div id="header">
		header
	</div>

	<div id="footer">
		footer
	</div>
</body>
</html>


本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1900689

less引用其他less文件

标签:less引用其他less文件

原文地址:http://suyanzhu.blog.51cto.com/8050189/1900689

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!