常用less小结

1.对于常用的,做了一个简单小结,后续如果还有别的,再继续完善

1.1less

/****border-radius系列****/
/**上左**/
.radiusTopleft(@radius:5px){
    border-top-left-radius:@radius;
    -webkit-border-top-left-radius:@radius;
    -moz-border-top-left-radius:@radius;
}

.radiusTopleft10{
    .radiusTopleft(10px)
}
/**上右**/
.radiusTopright(@radius:5px){
    border-top-right-radius:@radius;
    -webkit-border-top-right-radius:@radius;
    -moz-border-top-right-radius:@radius;
}

.radiusTopright10{
    .radiusTopright(10px)
}

/**下右**/
.radiusBottomright(@radius:5px){
    border-bottom-right-radius:@radius;
    -webkit-border-bottom-right-radius:@radius;
    -moz-border-bottom-right-radius:@radius;
}

.radiusBottomright10{
    .radiusBottomright(10px)
}

/**下左**/
.radiusBottomleft(@radius:5px){
    border-bottom-left-radius:@radius;
    -webkit-border-bottom-left-radius:@radius;
    -moz-border-bottom-left-radius:@radius;
}

.radiusBottomleft10{
    .radiusBottomleft(10px)
}

/**上**/
.radiusTop(@radius:5px){
    border-top-right-radius:@radius;
    -webkit-border-top-right-radius:@radius;
    -moz-border-top-right-radius:@radius;
    border-top-left-radius:@radius;
    -webkit-border-top-left-radius:@radius;
    -moz-border-top-left-radius:@radius;
}

.radiusTop10{
    .radiusTop(10px)
}

/**下**/
.radiusBottom(@radius:5px){
    border-bottom-right-radius:@radius;
    -webkit-border-bottom-right-radius:@radius;
    -moz-border-bottom-right-radius:@radius;
    border-bottom-left-radius:@radius;
    -webkit-border-bottom-left-radius:@radius;
    -moz-border-bottom-left-radius:@radius;
}

.radiusBottom10{
    .radiusBottom(10px)
}

/**所有**/
.radiusAll(@radius:5px){
    border-radius:@radius;
    -webkit-border-radius: @radius;
    -moz-border-radius: @radius;
}

.radiusAll10{
   .radiusAll(10px);
}

/****boxshadow系列****/

/**box-shadow: h-shadow v-shadow blur spread color inset;**/
/**
 * h-shadow:必需。水平阴影的位置。允许负值
 * v-shadow:必需。垂直阴影的位置。允许负值
 * blur:    可选。模糊距离。
 * spread:  可选。阴影的尺寸。   
 * color:   可选。阴影的颜色。请参阅 CSS 颜色值 
 * inset:   可选。将外部阴影 (outset) 改为内部阴影。
 * **/

/**普通,没有阴影的尺寸**/
.boxshadow(@right_left:5px,@bottom_top:5px,@box :5px,@box_color:#b6ebf7){
    box-shadow:@arguments;
   -moz-box-shadow:@arguments;
   -webkit-box-shadow:@arguments;
}

.boxshadow7-7-7_black{
  .boxshadow(7px,7px,7px,black);
}

/**常用,有阴影的尺寸**/
.boxshadow_spread(@right_left:5px,@bottom_top:5px,@box :5px,@spread :5px,@box_color:#b6ebf7){
    box-shadow:@arguments;
   -moz-box-shadow:@arguments;
   -webkit-box-shadow:@arguments;
}
.boxshadow0-0-14-3_rgba_01{
    .boxshadow_spread(0px,0px,14px,3px,rgba(0,0,0,0.1));
}

/**透明度系列**/
.rgba(@rgb_a:.4,@rgb_b:40){
    filter: alpha(opacity=@rgb_b); 
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=@{rgb_b})"; 
    opacity:@rgb_a;    
}
.rgba5{
    .rgba(.5,50);
}

/****背景图系列****/
.bg-img(@img:'//img-ads.csdn.net/2018/201811191651213306.jpg',@w:20px,@h:20px,@position_l:center,@position_t:center,@repeat:no-repeat){
    background-image: url(@img);
    background-size: @w @h;
    background-position: @position_l @position_t;
    background-repeat: @repeat;
}

.bg-img20{
   .bg-img('//img-ads.csdn.net/2018/201811191651213306.jpg',40px,40px,center,center,no-repeat);
}

/****居中系列****/
/**水平垂直居中**/
.pos_center(@w:50px,@h:50px){
    width: @w;
    height: @h;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -1/2*@w;
    margin-top: -1/2*@h;
}

.pos_center50{
    .pos_center(50px,50px);
}

/**水平居中**/
.pos_left(@w:50px,@h:50px){
    width: @w;
    height: @h;
    position: absolute;
    left: 50%;
    margin-left: -1/2*@w;
}
.pos_left50{
    .pos_left(50px,50px)
}

1.2编译的css

/****border-radius系列****/
/**上左**/
.radiusTopleft10 {
  border-top-left-radius: 10px;
  -webkit-border-top-left-radius: 10px;
  -moz-border-top-left-radius: 10px;
}
/**上右**/
.radiusTopright10 {
  border-top-right-radius: 10px;
  -webkit-border-top-right-radius: 10px;
  -moz-border-top-right-radius: 10px;
}
/**下右**/
.radiusBottomright10 {
  border-bottom-right-radius: 10px;
  -webkit-border-bottom-right-radius: 10px;
  -moz-border-bottom-right-radius: 10px;
}
/**下左**/
.radiusBottomleft10 {
  border-bottom-left-radius: 10px;
  -webkit-border-bottom-left-radius: 10px;
  -moz-border-bottom-left-radius: 10px;
}
/**上**/
.radiusTop10 {
  border-top-right-radius: 10px;
  -webkit-border-top-right-radius: 10px;
  -moz-border-top-right-radius: 10px;
  border-top-left-radius: 10px;
  -webkit-border-top-left-radius: 10px;
  -moz-border-top-left-radius: 10px;
}
/**下**/
.radiusBottom10 {
  border-bottom-right-radius: 10px;
  -webkit-border-bottom-right-radius: 10px;
  -moz-border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
  -webkit-border-bottom-left-radius: 10px;
  -moz-border-bottom-left-radius: 10px;
}
/**所有**/
.radiusAll10 {
  border-radius: 10px;
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
}
/****boxshadow系列****/
/**box-shadow: h-shadow v-shadow blur spread color inset;**/
/**
 * h-shadow:必需。水平阴影的位置。允许负值
 * v-shadow:必需。垂直阴影的位置。允许负值
 * blur:    可选。模糊距离。
 * spread:  可选。阴影的尺寸。   
 * color:   可选。阴影的颜色。请参阅 CSS 颜色值 
 * inset:   可选。将外部阴影 (outset) 改为内部阴影。
 * **/
/**普通,没有阴影的尺寸**/
.boxshadow7-7-7_black {
  box-shadow: 7px 7px 7px black;
  -moz-box-shadow: 7px 7px 7px black;
  -webkit-box-shadow: 7px 7px 7px black;
}
/**常用,有阴影的尺寸**/
.boxshadow0-0-14-3_rgba_01 {
  box-shadow: 0px 0px 14px 3px rgba(0, 0, 0, 0.1);
  -moz-box-shadow: 0px 0px 14px 3px rgba(0, 0, 0, 0.1);
  -webkit-box-shadow: 0px 0px 14px 3px rgba(0, 0, 0, 0.1);
}
/**透明度系列**/
.rgba5 {
  filter: alpha(opacity=50);
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
  opacity: 0.5;
}
/****背景图系列****/
.bg-img20 {
  background-image: url('//img-ads.csdn.net/2018/201811191651213306.jpg');
  background-size: 40px 40px;
  background-position: center center;
  background-repeat: no-repeat;
}
/****居中系列****/
/**水平垂直居中**/
.pos_center50 {
  width: 50px;
  height: 50px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -25px;
  margin-top: -25px;
}
/**水平居中**/
.pos_left50 {
  width: 50px;
  height: 50px;
  position: absolute;
  left: 50%;
  margin-left: -25px;
}

1.3html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/3.css"/>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			.clearfix:before, .clearfix:after {
			    content: '.';
			    display: block;
			    visibility: hidden;
			    font-size: 0;
			    line-height: 0;
			    width: 0;
			    height: 0;
			}
			.clearfix:after {
			  clear: both;
			}
			.clearfix {
			  zoom: 1;
			}
			.box{
				margin: 10px auto;
				padding: 0 10px;
				height: 50px;
				line-height: 50px;
				text-align: center;
				color: #fff;
				background-color: orange;
				float: left;
				margin-left: 10px;
			}
		</style>
	</head>
	<body>
		
		<div style="font-size: 20px;line-height: 30px;font-weight: bold;margin: 10px 0;">border-radius系列</div>
		<div class="clearfix">
			<div class="box radiusTopleft10">radiusTopleft10</div>
			<div class="box radiusTopright10">radiusTopleft10</div>
			<div class="box radiusBottomright10">radiusBottomright10</div>
			<div class="box radiusBottomleft10">radiusBottomleft10</div>
			<div class="box radiusTop10">radiusTop10</div>
			<div class="box radiusBottom10">radiusBottom10</div>
			<div class="box radiusAll10">radiusAll10</div>
		</div>
		<div style="font-size: 20px;line-height: 30px;font-weight: bold;margin: 10px 0;">boxshadow系列</div>
		<div class="clearfix">
			<div class="box boxshadow7-7-7_black">boxshadow7-7-7_black</div>
			<div class="box boxshadow0-0-14-3_rgba_01">boxshadow0-0-14-3_rgba_01</div>
		</div>
		<div style="font-size: 20px;line-height: 30px;font-weight: bold;margin: 10px 0;">透明度系列</div>
		<div class="clearfix">
			<div class="box rgba4">rgba4</div>
		</div>
		
		<div style="font-size: 20px;line-height: 30px;font-weight: bold;margin: 10px 0;">背景图系列</div>
		<div class="clearfix" style="width: 100;height: 100px;position: relative;">
			<div style="width: 50px;height: 50px;background-color: rgba(0,0,0,0.5);" class="bg-img20"></div>
		</div>
		
		<div style="font-size: 20px;line-height: 30px;font-weight: bold;margin: 10px 0;">居中系列</div>
		<div class="clearfix" style="width: 100%;height: 100px;position: relative;background: rgba(0,0,0,0.5);">
			<div style="background-color: orange;" class="pos_center50"></div>
		</div>
		<div style="width: 100%;height: 100px;position: relative;background: rgba(0,0,0,0.2);">
			<div style="background-color: orange;" class="pos_left50"></div>
		</div>
	
	</body>
</html>

1.4效果预览

2.说明

推荐博客:https://www.cnblogs.com/RuMengkai/p/6502057.html

推荐博客:https://www.cnblogs.com/grey-zhou/p/5796496.html

推荐:https://www.jianshu.com/p/d81496ed0e29

less用法见官网:http://lesscss.cn/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值