In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use pure CSS to achieve diamond loader effect", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "how to use pure CSS to achieve diamond loader effect" this article.
Code interpretation
Define dom, which contains nine child elements in a container:
Centered display:
Body {
Margin:0
Height:100vh
Display:flex
Align-items:center
Justify-content:center
Background-color:black
}
Defines the size of the container and child elements, which is a large square containing 9 small squares:
.loader {
Width:10em
Height:10em
Display:grid
Grid-template-columns:repeat (3Jing 1fr)
Grid-gap:0.5em
}
Adjust the pattern to include 9 small diamonds in the big diamond:
.loader {
Transform:rotate (45deg)
}
To color a small diamond in vertical units:
.loaderspan {
Background-color:var (--c)
}
.loaderspan:nth-child (7) {
-- c:tomato
}
.loaderspan:nth-child (4)
.loaderspan:nth-child (8) {
-- c:gold
}
.loaderspan:nth-child (1)
.loaderspan:nth-child (5)
.loaderspan:nth-child (9) {
-- c:limegreen
}
.loaderspan:nth-child (2)
.loaderspan:nth-child (6) {
-- c:dodgerblue
}
.loaderspan:nth-child (3) {
-- c:mediumpurple
}
Define animation effects:
.loaderspan {
Animation:blinking2slinearinfinite
Animation-delay:var (--d)
Transform:scale (0)
}
@ keyframesblinking {
0% 100% {
Transform:scale (0)
}
40% 80% {
Transform:scale (1)
}
}
Finally, set the delay for the small diamond to enhance the sense of motion:
.loaderspan:nth-child (7) {
-- dDRO _ 0s
}
.loaderspan:nth-child (4)
.loaderspan:nth-child (8) {
-- dvl 0.2s
}
.loaderspan:nth-child (1)
.loaderspan:nth-child (5)
.loaderspan:nth-child (9) {
-- dDUR 0.4s
}
.loaderspan:nth-child (2)
.loaderspan:nth-child (6) {
-- dvl 0.6s
}
.loaderspan:nth-child (3) {
-- dvl 0.8s
}
The above is all the content of this article "how to achieve diamond loader effect with pure CSS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
This article mainly introduces which tags are commonly used in HTML, which are introduced in great detail and have certain reference value. Friends who are interested must finish reading them. 1. The most basic HTML structure
Wechat
About us
Contact us
Product review
car news
thenatureplanet
More Form oMedia:
AutoTimes.
Bestcoffee.
SL News.
Jarebook.
Coffee Hunters.
Sundaily.
Modezone.
NNB.
Coffee.
Game News.
FrontStreet.
GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.