|
| 1 | +// 1px |
| 2 | +// 使用box-shadow都会让线有阴影,甚至颜色变浅 |
| 3 | +.border-1px(@color) { |
| 4 | + box-shadow: 0px 0px 1px 0px @color inset; |
| 5 | +} |
| 6 | + |
| 7 | +// transform -> less, scss |
| 8 | +.border-1px { |
| 9 | + position: relative; |
| 10 | + &::before { |
| 11 | + content: ""; |
| 12 | + position: absolute; |
| 13 | + left: 0; |
| 14 | + top: 0; |
| 15 | + width: 200%; |
| 16 | + border:1px solid #ccc; |
| 17 | + color: red; |
| 18 | + height: 200%; |
| 19 | + -webkit-transform-origin: left top; |
| 20 | + transform-origin: left top; |
| 21 | + -webkit-transform: scale(0.5); |
| 22 | + transform: scale(0.5); |
| 23 | + pointer-events: none; |
| 24 | + box-sizing: border-box; |
| 25 | + @media screen and (min-device-pixel-ratio:3), (-webkit-min-device-pixel-ratio:3) { |
| 26 | + width: 300%; |
| 27 | + height: 300%; |
| 28 | + -webkit-transform: scale(0.33); |
| 29 | + transform: scale(0.33); |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +.border-1px { |
| 35 | + overflow: hidden; |
| 36 | + position: relative; |
| 37 | + border: none!important; |
| 38 | +} |
| 39 | +.border-1px::after { |
| 40 | + content: "."; |
| 41 | + position: absolute; |
| 42 | + left: 0; |
| 43 | + bottom: 0; |
| 44 | + width: 100%; |
| 45 | + height: 1px; |
| 46 | + background-color: #ccc; |
| 47 | + -webkit-transform-origin: 0 0; |
| 48 | + transform-origin: 0 0; |
| 49 | + -webkit-transform: scaleY(0.5); |
| 50 | + transform: scaleY(0.5); |
| 51 | +} |
| 52 | + |
| 53 | +// media |
| 54 | +.border-1px { |
| 55 | + border: 1px solid #ccc; |
| 56 | +} |
| 57 | +@media screen and (-webkit-min-device-pixel-ratio: 2) { |
| 58 | + .border-1px { |
| 59 | + border: 1px solid #ccc; |
| 60 | + } |
| 61 | +} |
| 62 | +@media screen and (-webkit-min-device-pixel-ratio: 3) { |
| 63 | + .border-1px { |
| 64 | + border: 1px solid #ccc; |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +// clear 清除浮动 |
| 69 | +.clearfix { |
| 70 | + *zoom: 1 |
| 71 | +} |
| 72 | +.clearfix:before, .clearfix:after { |
| 73 | + display: table; |
| 74 | + line-height: 0; |
| 75 | + content: ""; |
| 76 | +} |
| 77 | +.clearfix:after { |
| 78 | + clear: both |
| 79 | +} |
| 80 | + |
| 81 | +// 单行显示 |
| 82 | +.single-line-camp { |
| 83 | + overflow: hidden; |
| 84 | + text-overflow: ellipsis; |
| 85 | + white-space: nowrap; |
| 86 | +} |
| 87 | + |
| 88 | +// 多行显示, 以下方式注意浏览器兼容 |
| 89 | +/* |
| 90 | + * 在webkit浏览器或移动端(绝大部分是webkit内核的浏览器)可以直接使用webkit的css扩展属性(webkit是私有属性)-webkit-line-clamp; |
| 91 | + * 注意:这是一个不规范的属性,它没有在CSS的规范草案中 |
| 92 | + * -webkit-line-clamp用来限制在一个块元素显示的文本行数,为了实现效果,他要与一下webkit属性结合使用: |
| 93 | + * display: -webkit-box;(必须结合的属性,将对象作为弹性伸缩盒子模型展示) |
| 94 | + * -webkit-box-orient(必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式) |
| 95 | + */ |
| 96 | +// less |
| 97 | +.line-camp(@clamp: 3) { |
| 98 | + text-overflow: -o-ellipsis-lastline; |
| 99 | + overflow: hidden; |
| 100 | + text-overflow: ellipsis; |
| 101 | + display: -webkit-box; |
| 102 | + -webkit-line-clamp: @clamp; |
| 103 | + -webkit-box-orient: vertical; |
| 104 | +} |
| 105 | +// scss mixin |
| 106 | +@mixin line-camp($clamp) { |
| 107 | + text-overflow: ellipsis; |
| 108 | + overflow: hidden; |
| 109 | + display: -webkit-box; |
| 110 | + -webkit-line-clamp: $clamp; |
| 111 | + -webkit-box-orient: vertical; |
| 112 | +} |
| 113 | + |
| 114 | +// 文字对齐 |
| 115 | +.text-align-style (@align: 'justify') { |
| 116 | + text-align: @align; |
| 117 | + text-align-last: @align; |
| 118 | +} |
| 119 | +.text-align-style::after { |
| 120 | + content: ''; |
| 121 | + display: inline-block; |
| 122 | + width: 100%; |
| 123 | +} |
0 commit comments