移動(dòng)端1px邊框詳解

第一種

.b-b?{

??position:?relative;

}

.b-b:after?{

??content:?"?";

??position:?absolute;

??left:?0;

??bottom:?0;

??right:?0;

??/*height:?1px;*/

??border-top:?1px?solid?#d9d9d9;

??color:?#d9d9d9;

??-webkit-transform-origin:?0?0;

??transform-origin:?0?0;

??-webkit-transform:?scaleY(0.5);

??transform:?scaleY(0.5);

}

node-sass 和sass-loader(vue)

第二種

@media (-webkit-min-device-pixel-ratio: 1.5),

(min-device-aspect-ratio: 1.5) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.7); //1.5 * 0.7接近1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 2),

(min-device-aspect-ratio: 2) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.5); //2 * 0.5 = 1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 2.5),

(min-device-aspect-ratio: 2.5) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.4); //2.5 * 0.4 = 1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 3),

(min-device-aspect-ratio: 3) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.333); //3 * 0.333接近 1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 3.5),

(min-device-aspect-ratio: 3.5) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.2857); //3.5 * 0.2857接近 1

? ? }

? }

}

封裝

@mixin border($height, $color) {? ? //封裝成的border? height指的是大小,到時(shí)候需要定位 加z-index;不然會(huì)被遮住?

? position: relative;

? &::after {

? ? position: absolute;

? ? display: block;

? ? left: 0;

? ? bottom: 0;

? ? width: 100%;

? ? height: .78rem;

? ? border: $height solid $color;

? ? content: '';

? ? border-radius: .06rem;

? }

}

@mixin border-bottom($height, $color) {? //封裝成的border-bottom

? position: relative;

? &::after {

? ? position: absolute;

? ? display: block;

? ? left: 0;

? ? bottom: 0;

? ? width: 100%;

? ? border-top: $height solid $color;

? ? content: '';

? }

}

@mixin border-top($height, $color) { // 封裝成的border-top

? position: relative;

? &::after {

? ? position: absolute;

? ? display: block;

? ? left: 0;

? ? top: 0;

? ? width: 100%;

? ? border-top: $height solid $color;

? ? content: '';

? }

}

調(diào)用

@include border(1px, #d7d7d7);

第三種

@media (-webkit-min-device-pixel-ratio: 1.5),

(min-device-aspect-ratio: 1.5) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.7); //1.5 * 0.7接近1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 2),

(min-device-aspect-ratio: 2) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.5); //2 * 0.5 = 1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 2.5),

(min-device-aspect-ratio: 2.5) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.4); //2.5 * 0.4 = 1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 3),

(min-device-aspect-ratio: 3) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.333); //3 * 0.333接近 1

? ? }

? }

}

@media (-webkit-min-device-pixel-ratio: 3.5),

(min-device-aspect-ratio: 3.5) {

? .border-1px {

? ? &::after {

? ? ? transform: scaleY(0.2857); //3.5 * 0.2857接近 1

? ? }

? }

}

直接寫border 就可以了

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、使用真實(shí)手機(jī)測(cè)試未發(fā)布網(wǎng)頁(yè)的方法 方法① 在虛擬機(jī)中搭建xampp,將文件通過(guò)FTP傳到虛擬機(jī),在一個(gè)局域網(wǎng)中...
    fastwe閱讀 804評(píng)論 0 0
  • 1.背景圖漸變.ui-border-t { border-top: 1px solid #e0e0e0 }.ui-...
    RiverSouthMan閱讀 769評(píng)論 0 0
  • 關(guān)于css常見(jiàn)問(wèn)題,大多是移動(dòng)端的。 簡(jiǎn)單的排版規(guī)則:條目與條目之間空兩行,每條內(nèi)容部分分段空一行。標(biāo)點(diǎn)符號(hào)全部用...
    蘇水兒閱讀 5,155評(píng)論 0 9
  • 有一段時(shí)間沒(méi)有跑山,其實(shí)普通跑步也有好長(zhǎng)時(shí)間沒(méi)有過(guò)了。 五點(diǎn)半起床,糾結(jié)斗爭(zhēng)好久才換好了衣服,出門時(shí)已經(jīng)六點(diǎn)出頭。...
    天香后街閱讀 375評(píng)論 0 0
  • 曾經(jīng)傷心知為誰(shuí) 爾今未知儂心醉 獨(dú)自沉醉偷灑淚 只待他日把緣隨 爾今著迷只為奇 未知儂今心早醉 君若急待儂快醒 何...
    逸而全真閱讀 234評(píng)論 0 2

友情鏈接更多精彩內(nèi)容