javascript - 我的倾斜 js 不工作卡不倾斜 4 小时内需要帮助
问题描述
所以伙计们,我创建了一个网站,其中我有一张卡片,听到的是它的 html 代码
<div class="about-indiamain" data-tilt>
Main Content</div>
<div class="txt">India is the country that occupies the larger part of South Asia. Our government is a
democratic republic that represents highly diverse culture and history.We have hundreds of languages and
religion and roughly one-sixth of the world’s total population so is the second most populous country, after
China
.India is also an unique land of diverse colours, rich geography,monuments and history. From the busy
streets of Mumbai to the silet shores of the Andaman Islands,from sandy dry dessert of Rajasthan to rainy
streets of Sikkim India offers a wide feast for our senses.India also borns athlete who make it to the top
like Neeraj Chopra who have won gold in Tokyo Olypics 2021.
India is called incredible not only through monuments but also through yoga which proves to bring peace to
mind.People all over the world comes to learn yoga.India is also known for its rich ancient medical
knowledge that is Ayurveda.India is one of the best country in the world in terms of science.India borns
artistics creative young minds who later go abroad in search of more money and become "SCIENTISTS" there .
Even when we look into discoveries story of zero revolvess around Aryabhatta,Sushruta was a surgeon known
today as the “Father of Plastic Surgery”
Sushruta developed different surgical techniques & invented the practice of cosmetic surgery so called
plastic surgery.<br>This are my reasons with which I can state my India is incredible
</div>
我已将倾斜 js 命名为 vanilla-tilt.js 并添加了正确的脚本就是这样:-
<script type="text/javascript" src="vanilla-tilt.js"></script>
如果有人想要的话,我也做了适当的造型:_
.about-indiamain{
margin-left: 30%;
margin-top: 10px;
width: fit-content;
font-size: 32px;
background-color: yellowgreen;
}
记住类名:-about-indiamain
解决方案
您是在 HTML 中的 body 标记之前还是之后添加脚本?
如果它在 body 之前,请尝试将它移动到 body 标签之后,这样它就会在 DOM 加载之后加载。