In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to achieve the starry sky effect with Vue". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to achieve the starry sky effect with Vue".
The effect of starry sky is as follows
1. Star background sub-component
Export default {name: 'StarBackground', props: {}, data () {return {starsCount: 1200, distance: 800}}, mounted () {this.initStars ()} Methods: {initStars () {let starArr = this.$refs.star starArr.forEach (item = > {let speed = 0.2 + (Math.random () * 1) let thisDistance = this.distance + (Math.random () * 300) item.style.transformOrigin = `00 ${thisDistance} px` item.style.transform = `translate3d (0,0) -${thisDistance} px) rotateY (${(Math.random () * 360)} deg) rotateX (${(Math.random () *-50)} deg) scale (${speed}, ${speed}) `} @ keyframes rotate {0% {transform: perspective (600px) rotateZ (20deg) rotateX (- 40deg) rotateY (0) } 100% {transform: perspective (600px) rotateZ (20deg) rotateX (- 40deg) rotateY (- 360deg);}. Stars {transform: perspective (500px); transform-style: preserve-3d; position: absolute; perspective-origin: 50% 100%; left: 50%; animation: rotate 90s infinite linear; bottom:-200px;} .star {width: 2px; height: 2px; background: # f7f7b8; position: absolute; top: 0; left: 0; backface-visibility: }
two。 Login page reference subcomponent
Import StarBackground from'. / components/StarBackground'export default {beforeCreate: function () {document.getElementsByTagName ('body') [0] .className =' body-bg'}, components: {StarBackground}}. Body-bg {background-attachment: fixed; overflow: hidden;}. Login-container {height: 100%; width: 100%; overflow: hidden; background-color: # 050608;}
Background-attachment: fixed; is very important. You need to fix the interface, or else the drop-down will go blank.
At this point, I believe you have a deeper understanding of "how to achieve starry effect in Vue". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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





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.