溢出顯示省略號
參過參數可以只是單/多行.
/** * 溢出省略號 * @param {Number} 行數 */ @mixin ellipsis($rowCount: 1) { @if $rowCount <=1 { overflow: hidden; text-overflow: ellipsis; white-space: 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, 你可以根據需要傳入(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==type-of($directionMaps); @if ($isOnlyOneDir) { $directionMaps: ($directionMaps); } @each $directionMap in $directionMaps { border-#{$directionMap}: 1px solid $color; } // 判斷圓角是list還是number @if (list==type-of($radius)) { border-radius: nth($radius, 1) nth($radius, 2) nth($radius, 3) nth($radius, 4); } @else { border-radius: $radius; } @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: 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