用Less CSS定义常用的CSS3效果函数

定义圆角及调用
/*
定义圆角
@radius 圆角大小
*/
.round(@radius:5px){
    border-radius:@radius;
    -webkit-border-radius: @radius;
    -moz-border-radius: @radius;
}
.round7{
   .round(7px);
}

image

 
定义盒子阴影及调用
/*
盒子阴影
@right_left 右边阴影为正数 左边负数
@bottom_top 下边阴影为正数 上边负数
@box  阴影大小
@box_color 阴影颜色
*/
.boxshadow(@right_left:5px,@bottom_top:5px,@box :5px,@box_color:#b6ebf7){
    box-shadow:@arguments;
   -moz-box-shadow:@arguments;
   -webkit-box-shadow:@arguments;
}
.boxshadow7{
  .boxshadow(7px,7px,7px,black);
}

image

 
定义文字阴影及调用
/*
文字阴影,可以指定多组阴影
@right_left1 右边阴影为正数 左边负数
@bottom_top1 下边阴影为正数 上边负数
@text  阴影大小
@text_color 阴影颜色
*/
.textshadow(@right_left1:5px,@bottom_top1:5px,@text :5px,@tetx_color:#b6ebf7){
    text-shadow:@arguments;
}
.r_b_textshadow{
  .textshadow();
}

image

定义透明度及调用
/*
透明度 或渐变 1为不透明 0透明
css3 rgba(110, 142, 185, .4)!important;前三个是颜色值 后一个是透明值
用来兼容所有浏览器
*/
.rgba(@rgba_a:.4,@rgb_b:40){
    filter: alpha(opacity=@rgb_b); 
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=@{rgb_b})"; 
    opacity:@rgb_a;    
}
.rgba4{
    .rgba();
}

image

定义列布局及调用
/*
列布局
@c1 列数
@c2 列宽
@c3 列间距
@c4 边框样式
*/
.column(@c1:3,@c2:310px,@c3:10px,@c4:1px solid #ccc){
    column-count:@c1;
    column-width:@c2;
    column-gap:@c3;
    column-rule:@c4;
    -webkit-column-count:@c1;
    -webkit-column-width:@c2;
    -webkit-column-gap:@c3;
    -webkit-column-rule:@c4;
    -moz-column-count:@c1;
    -moz-column-width:@c2;
    -moz-column-gap:@c3;
    -moz-column-rule:@c4;
}
.my_column{
    .column(3,50px,3px,1px solid #ccc);
}

image

定义背景渐变及调用
/*背景渐变
@start  渐变开始颜色
@end  结束颜色
*/
.bg(@start :#00ffff,@end :#9fffff){
    background:-webkit-gradient(linear,0 0, 0 100%,from(@start),to(@end));
    background:-moz-linear-gradient(top,@start ,@end);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=@start ,
                endColorstr=@end ,grandientType=0);
}
.my_bg{
    .bg(red,yellow);
}

image

定义轮廓内部框及调用
/*
画轮廓 就是内部框
@outline 样式
@outline1 间距 负数在内部
*/
.outline(@outline:1px solid #699,@outline1:-10px){
    outline:@outline;
    outline-offset:@outline1;
}
.my_outline{
    .outline();
}

image

定义旋转,菱形旋转,缩放,移动及调用
/*
旋转角度
@ro定义度数 
IE不支持 滤镜支持0,1,2,3
*/
.rotate(@ro :30deg){
        transform: rotate(@ro);
      -webkit-transform: rotate(@ro);
      -moz-transform: rotate(@ro);
      -o-transform: rotate(@ro);
      filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
.rotate50{
    .rotate(50deg);
}

/*
菱形旋转角度
@x横向缩放比例
@y纵向缩放比例
*/
.skew(@roX :30deg,@roY :30deg){
        transform: skew(@roX,@roY);
      -webkit-transform: skew(@roX,@roY);
      -moz-transform: skew(@roX,@roY);
      -o-transform: skew(@roX,@roY);
      -ms-transform: skew(@roX,@roY) ;
}
.skew30{
    .skew(50deg);
}

/*
放大缩小
@x横向缩放比例
@y纵向缩放比例
*/
.scale(@x :1.2,@y :1.2){
        transform: scale(@x,@y);
      -webkit-transform: scale(@x,@y);
      -moz-transform: scale(@x,@y);
      -o-transform: scale(@x,@y);
      -ms-transform: scale(@x,@y);
}
.my_scale{
      .scale();
}

/*
移动距离
@x横向移动距离
@y纵向移动距离
*/
.translate(@x :80px,@y :80px){
        transform: translate(@x,@y);
      -webkit-transform: translate(@x,@y);
      -moz-transform: translate(@x,@y);
      -o-transform: translate(@x,@y);
      -ms-transform: translate(@x,@y);
}
.translate80{
      .translate();
}

/*
综合上面4种变化,效果看下面的过度动画
@rotate
@scale
@skew
@translate
*/
.transform(@rotate :360deg,@scaleX :1,@scaleY :1,@skewX :0deg,@skewY :0deg,@translateX :100px,@translateY :0px){
   transform: rotate(@rotate) scale(@scaleX,@scaleY) skew(@skewX,@skewY) translate(@translateX,@translateY);
   -webkit-transform: rotate(@rotate) scale(@scaleX,@scaleY) skew(@skewX,@skewY) translate(@translateX,@translateY);
   -moz-transform: rotate(@rotate) scale(@scaleX,@scaleY) skew(@skewX,@skewY) translate(@translateX,@translateY);
   -o-transform: rotate(@rotate) scale(@scaleX,@scaleY) skew(@skewX,@skewY) translate(@translateX,@translateY);
   -ms-transform: rotate(@rotate) scale(@scaleX,@scaleY) skew(@skewX,@skewY) translate(@translateX,@translateY);
   filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
.my_transform{
      .transform();
}
定义过度动画及调用
/*
过度动画 
id是css属性
2s过度时间 0s是开始时间
ease-in进入
*/
.tran(@t :id 2s ease-in 0s){
    transition:@t ;
    -moz-transition:@t ;
    -o-transition:@t ;
    -webkit-transition:@t ;
}
.my_tran{
   &:hover{
   .transform();
   .tran(all 2s ease-in 0s);
   }
}
定义Animation动画及调用
/*
less文件中定义的函数
Animation 动画 
@animation-name规定需要绑定到选择器的 keyframe 名称
@animation-duration规定完成动画所花费的时间,以秒或毫秒计,默认是 0。
@animation-timing-function规定动画的速度曲线。默认是 "ease"。
@animation-delay规定在动画开始之前的延迟。默认是 0。
@animation-iteration-count规定动画应该播放的次数。默认是 1。
@animation-direction规定是否应该轮流反向播放动画。默认是 "normal"。
*/
.animation(@animation-name,@animation-duration,@animation-timing-function,
                @animation-delay,@animation-iteration-count,@animation-direction){
    animation: @arguments;
    /* Firefox: */
    -moz-animation: @arguments;
    /* Safari 和 Chrome: */
    -webkit-animation: @arguments;
    /* Opera: */
    -o-animation: @arguments;
}
.my_animation{
   .animation(mykeyframes,5s,linear,2s,infinite,normal);
}

/***CSS定义的keyframes如下:****/
@keyframes mykeyframes
{
0%   {background: red; left:0px; top:0px;}
25%  {background: yellow; left:200px; top:0px;}
50%  {background: blue; left:200px; top:200px;}
75%  {background: green; left:0px; top:200px;}
100% {background: red; left:0px; top:0px;}
}

@-moz-keyframes mykeyframes /* Firefox */
{
0%   {background: red; left:0px; top:0px;}
25%  {background: yellow; left:200px; top:0px;}
50%  {background: blue; left:200px; top:200px;}
75%  {background: green; left:0px; top:200px;}
100% {background: red; left:0px; top:0px;}
}

@-webkit-keyframes mykeyframes /* Safari 和 Chrome */
{
0%   {background: red; left:0px; top:0px;}
25%  {background: yellow; left:200px; top:0px;}
50%  {background: blue; left:200px; top:200px;}
75%  {background: green; left:0px; top:200px;}
100% {background: red; left:0px; top:0px;}
}

@-o-keyframes mykeyframes /* Opera */
{
0%   {background: red; left:0px; top:0px;}
25%  {background: yellow; left:200px; top:0px;}
50%  {background: blue; left:200px; top:200px;}
75%  {background: green; left:0px; top:200px;}
100% {background: red; left:0px; top:0px;}
}

 

 

参考引用

http://my.oschina.net/u/98589/blog/57510
http://lesscss.org/
http://www.w3school.com.cn/
http://www.css3maker.com/

Less在线编译工具:

http://tool.oschina.net/less 

 

转载于:https://www.cnblogs.com/fastmover/p/4310727.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值