【问题标题】:My tilt js is not working the card is not tilting need help within 4 hours我的倾斜 js 不工作卡不倾斜 4 小时内需要帮助
【发布时间】:2022-05-05 20:46:04
【问题描述】:

所以伙计们,我创建了一个网站,其中我有一张卡片,听到的是它的 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

【问题讨论】:

  • 您应该检查控制台 (F12) 是否有任何错误

标签: javascript html css cdn tilt


【解决方案1】:

您是在 HTML 中的 body 标记之前还是之后添加脚本?

如果是在body之前,试着把它移到body标签之后,让它在DOM加载之后加载。

【讨论】:

    【解决方案2】:

    有同样的问题。 正如雷诺建议的那样,我检查了控制台并看到:

    来自 your-domain/vanilla-tilt.js 的请求被阻止,原因是 to (“text/html”) MIME (X-Content-Type-Options: nosniff) mdn web docs

    如何使用tilt.js的示例,来自他们的文档:

    <body>
        <div data-tilt></div> <!-- Tilt element -->
        <script src="jquery.js" ></script> <!-- Load jQuery first -->
        <script src="tilt.js"></script> <!-- Load Tilt.js library -->
    </body>
    

    他们建议在正文结束标记之前添加脚本。 我将它们添加到 head 元素中,对两个脚本都使用了 defer 属性。

    我在jquery cdn获取了 jQuery 脚本

    然后我创建了一个 tilt.js 文件并在那里粘贴了一个jQuery code

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 2019-12-15
      • 1970-01-01
      • 2014-08-08
      • 2023-03-23
      • 1970-01-01
      • 2011-10-23
      • 2012-11-15
      • 2016-12-25
      相关资源
      最近更新 更多