您好,登錄后才能下訂單哦!
如何使用css實現(xiàn)骨架屏?相信大部分人都還沒學(xué)會這個技能,為了讓大家學(xué)會,給大家總結(jié)了以下內(nèi)容,話不多說,一起往下看吧。
通過after
偽元素生成骨架樣式,并通過absolute
覆蓋到實際元素上
.skt-loading {
pointer-events: none; /* 加載中阻止事件 */
.skeleton {
position: relative;
overflow: hidden;
border: none !important;
border-radius: 5px;
background-color: transparent !important;
background-image: none !important;
&::after {
content: '';
position: absolute;
left: 0;
top: 0;
z-index: 9;
width: 100%;
height: 100%;
background-color: #EBF1F8;
display: block;
}
/* 下面這部分都是自定義的,看需求修改 */
&:not(.not-round)::after {
border-radius: 4px;
}
&:not(.not-before)::before {
position: absolute;
top: 0;
width: 30%;
height: 100%;
content: "";
background: linear-gradient(to right,rgba(255,255,255,0) 0,
rgba(255,255,255,.3) 50%,rgba(255,255,255,0) 100%);
transform: skewX(-45deg);
z-index: 99;
animation: skeleton-ani 1s ease infinite;
display: block;
}
&.badge {
&::after {
background-color: #F8FAFC;
}
}
}
}
@keyframes skeleton-ani { /* 骨架屏動畫 */
from {
left: -100%;
}
to {
left: 150%;
}
}
關(guān)于使用css實現(xiàn)骨架屏的方法就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。