LESS第五课(匹配模式 导入其他的less文件)

//记住,@_一定会被执行,第一开始执行的,然后是执行应该执行的啊
就是通过混合的((第一个字符串形参)),来确定具体要执行哪一个同名混合

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		/*@_:代表通用的匹配模式.
		什么是通用的匹配模式?
		他的优先级最高的,如果同名的混合名称,会优先执行通用匹配模式中的代码@_.
		.triangle(@_,@width,@color)
		{
			width:0;
			height:0;
			border-style:solid solid solid solid;
		}
		.triangle(Down,@width,@color)
		{
			border-width:@width;
			border-color:@color transparent transparent transparent ;
		}
		.triangle()
		{
			border-width:@width;
			border-color:transparent transparent @color  transparent;
		}
		.triangle(Left,@width,@color)
		{
			border-width:@width;
			border-color:transparent  transparent transparent @color;
		}
		div
		{
			//.triangle(Right,80px,green);
			.triangle(Down, 80px, green);
		}
		*/
	/*编译后的css代码*/
	div {
  width: 0;
  height: 0;
  border-style: solid solid solid solid;
  border-width: 80px;
  border-color: green transparent transparent transparent;
}

	</style>
</head>
<body>
	<div></div>
</body>
</html>

在这里插入图片描述

导入其他的less文件:
//这下面是导入的文件=====================

 .triangle(@_, @width, @color){
  width: 0;
  height: 0;
  border-style: solid solid solid solid;
}
.triangle(Down, @width, @color){
  //width: 0;
  //height: 0;
  border-width: @width;
  //border-style: solid solid solid solid;
  border-color: @color transparent transparent transparent;
}
.triangle(Top, @width, @color){
  //width: 0;
  //height: 0;
  border-width: @width;
  //border-style: solid solid solid solid;
  border-color: transparent transparent @color transparent;
}
.triangle(Left, @width, @color){
  //width: 0;
  //height: 0;
  border-width: @width;
  //border-style: solid solid solid solid;
  border-color: transparent @color transparent transparent;
}
.triangle(Right, @width, @color){
  //width: 0;
  //height: 0;
  border-width: @width;
  //border-style: solid solid solid solid;
  border-color: transparent transparent transparent @color;
}
==========================================

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		/*@import "triangle.less";/*.less可以省略,为什么,因为在less文件中只能导入less的文件*/
		/*div
		{
			.triangle(Down,40px,red);
		}*/
		/*编译后的css文件*/
		div {
  width: 0;
  height: 0;
  border-style: solid solid solid solid;
  border-width: 40px;
  border-color: #ff0000 transparent transparent transparent;
}

	</style>
</head>
<body>
	<div></div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贵哥的编程之路(热爱分享)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值