【问题标题】:Html file not displaying anythingHtml 文件不显示任何内容
【发布时间】:2021-11-09 10:13:36
【问题描述】:

当从本地主机打开时,它不会在浏览器上显示任何内容。但是通过 VSC 编辑器上的实时服务器打开时会显示所有内容

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Expanding Cards</title>
</head>

<body>

    <div class="container">

        <div class="panel active" style="background-image: url(/images/messi.jpg);">
            <h3>Lionel Messi</h3>
        </div>

        <div class="panel" style="background-image: url(/images/pique.jpg);">
            <h3>Gerard Pique</h3>
        </div>

        <div class="panel" style="background-image: url(/images/pedri.jpg);">
            <h3>Pedri Gonzalez</h3>
        </div>

        <div class="panel" style="background-image: url(/images/alba.jpg);">
            <h3>Jordi Alba</h3>
        </div>

        <div class="panel" style="background-image: url(/images/griezmann.webp);">
            <h3>Antoine Griezmann</h3>
        </div>

    </div>

    <script src="script.js"></script>
</body>

</html>
        

希望找到任何解决方法。请尝试查看所有部分,我已正确使用代码格式

【问题讨论】:

  • 在控制台中查找任何错误。如果可以,请提供更多详细信息
  • 欢迎来到 StackOverflow,请更新您的问题,否则它将被否决和/或关闭。只写“我写了代码,但它不起作用”不是社区要求的形式的问题。首先请阅读how to ask a question
  • 请提供有关代码/任何错误的更多信息?
  • 您可以添加有关应用程序上显示的内容或您如何运行此 HTML 页面的信息。 @WaliWaqar 如果请求至少到达所需页面,查看控制台错误是一个不错的选择。
  • @WaliWaqar 更新

标签: javascript html css reactjs


【解决方案1】:
  1. 确保文件路径正确(这意味着样式表和 JavaScript 文件与 HTML 文件位于同一位置

  2. 确保清除缓存,然后刷新页面。

【讨论】:

    猜你喜欢
    • 2016-01-26
    • 1970-01-01
    • 1970-01-01
    • 2022-08-04
    • 2016-06-18
    • 2019-04-13
    • 1970-01-01
    • 2015-03-08
    • 1970-01-01
    相关资源
    最近更新 更多