Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

html - How to lazy load an image in CSS

.image--about {
    background: url(../img/ZIZF.gif) no-repeat center;
    background-size: cover
}

I have this CSS. I want to use lazy loading to following images that I load via CSS, can you please help me out?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't know if it possible to apply lazy loading by css but it 's possible with HTML by adding single attribute loading="lazy"

<img src="myimage.jpg" loading="lazy" alt="..." />

other values for loading like eager and auto

others method will required JavaScript check this ?? Five Ways to Lazy Load Images for Better Website Performance


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...