下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、web前端入门到实战:常用的5个css代码封装成mixin复用在写css的时候, 无数样式都是很常用但是写起来很棘手, 虽然现在有无数成熟的ui框架, 但是我们也不能一个容易的活动页也引入那么大个框架吧?在工作中我也攒下了不少常用css, 我把他们封装成了mixin, 选择了5个共享给大家, 希翼大家喜爱.溢出显示省略号参过参数可以只是单/多行./* 溢出省略号* param number 行数*/mixin ellipsis($rowcount: 1) if $rowcount <=1 overflow: hidden;text-overflow: ellipsis;white-spa
2、ce: nowrap; else min-width: 0;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: $rowcount;-webkit-box-orient: vertical;真.1px边框移动端因为像素密度比的问题, 实际的1px边框看起来比较粗, 假如想要更"细"可以用法下面的代码. 不同像素密度比的设备都可以兼容(pc/手机), 还支持随意数量圆角./* 真.1px边框* list: 多个方向边框, 默认值为bottom, 你可
3、以按照需要传入(top, left, bottom, right) 4个方向;* color 边框的色彩, 默认ccc;* list 4个圆角半径, 默认0;* string 一个高级设置, 普通都不需要改动, 因为细边框的实现用法了css的伪类, 所以为了规避可能浮现的样式矛盾, 我们可以自己指定用法:after还是:before, 默认after;*/mixin thinborder($directionmaps: bottom,$color: ccc,$radius: (0,0,0,0),$position: after) / 是否惟独一个方向$isonlyonedir: string=
4、type-of($directionmaps);if ($isonlyonedir) $directionmaps: ($directionmaps);each $directionmap in $directionmaps border-$directionmap: 1px solid $color;/ 推断圆角是list还是numberif (list=type-of($radius) border-radius: nth($radius, 1)nth($radius, 2)nth($radius, 3)nth($radius, 4); else border-radius: $radiu
5、s;media only screen and (-webkit-min-device-pixel-ratio: 2) & position: relative;/ 删除1像素密度比下的边框each $directionmap in $directionmaps border-$directionmap: none;&:$position content: ""position: absolute;top: 0;left: 0;display: block;width: 200%;height: 200%;transform:
6、 scale(0.5);box-sizing: border-box;padding: 1px;transform-origin: 0 0;pointer-events: none;border: 0 solid $color;each $directionmap in $directionmaps border-$directionmap-width: 1px;/ 推断圆角是list还是numberif (list=type-of($radius) border-radius: nth($radius, 1) *2nth($radius, 2) *2nth($radius, 3) *2nth
7、($radius, 4) *2; else border-radius: $radius * 2;media only screen and (-webkit-min-device-pixel-ratio: 3) &:$position / 推断圆角是list还是numberif (list=type-of($radius) border-radius: nth($radius, 1) *3nth($radius, 2) *3nth($radius, 3) *3nth($radius, 4) *3; else border-radius: $radius * 3;width:
8、300%;height: 300%;transform: scale(0.3333);等边三角形常用来做下拉菜单的方向指示, 假如你做的页面就是个容易的活动页, 引入"饿了么"一类的ui就有些大材小用了, 借助"三角形"你可以自己做一个容易的./* 等边三角形* param string 尺寸* param color 色彩* param string 方向*/mixin triangle($size: 5px, $color: rgba(0, 0, 0, 0.6), $dir: bottom) width: 0;heig
9、ht: 0;border-style: solid;if (bottom=$dir) border-width: $size $size 0 $size;border-color: $color transparent transparent transparent; else if (top=$dir) border-width: 0 $size $size $size;border-color: transparent transparent $color transparent; else if (right=$dir) border-width: $size 0 $size $size
10、;border-color: transparent transparent transparent $color; else if (left=$dir) border-width: $size $size $size 0;border-color: transparent $color transparent transparent;loading这是一个"半圆边框"旋转的loading, 你可以按照业务需求自己指定圆的半径.mixin loading-half-circle($width: 1em) display: inline-block;heig
11、ht: $width;width: $width;border-radius: $width;border-style: solid;border-width: $width/10;border-color: transparent currentcolor transparent transparent;animation: rotate 0.6s linear infinite;vertical-align: middle;棋盘假如你做一些界面生成器工具(类易企秀)你会用到./* 棋盘背景* param color 背景色*/mixin bgchessboard($color: aaa) background-image: linear-gradient(45deg,$color 25%,transparent 25%,transparent 75%,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年中国疾病预防控制中心人事处招聘工作人员备考题库及参考答案详解一套
- 2026年初中语文、初中数学、初中物理、高中物理教师招聘备考题库及参考答案详解
- 2026年安能集团二局电力建设发展(厦门)有限公司招聘备考题库有答案详解
- 2026年成都郫都西汇三九八医院公开招聘人员备考题库及参考答案详解
- 2026年山东省滕州市第一中学山师大校园招聘备考题库(一)及参考答案详解一套
- 2026年廊坊市国资商贸物流投资集团有限公司招聘备考题库完整答案详解
- 2026年成都市温江区涌泉街道社区卫生服务中心编外人员招聘备考题库及1套完整答案详解
- 2026年国家电投集团内蒙古白音华煤电有限公司露天矿招聘备考题库带答案详解
- 2026年德州市第六人民医院公开招聘备案制工作人员45人备考题库及完整答案详解一套
- 2026年四川省旅游投资集团有限责任公司招聘备考题库及参考答案详解一套
- 水电维修工面试题库含答案
- 2025年中医执业医师考试试卷及答案
- 土地整治项目课件
- 2025河北邯郸市武安市正通食品药品检验技术服务中心有限公司招聘食品检测专业技术人员4人参考模拟试题及答案解析
- 道路施工临时交通疏导方案
- 2025年度医务科工作总结报告
- 管理学原理期末总复习重点
- 2025年企业战略研究员招聘面试参考题库及答案
- 电力工程结算管理
- 广东省农作物植保员职业技能竞赛考试题库含答案
- 中国铁路昆明局集团有限公司招聘笔试真题2024
评论
0/150
提交评论