javascript - CSS 未应用于页面

标签 javascript jquery html css web

我目前有一个相当简单的页面,由于某种原因没有应用 maincss.css,它只是将背景设置为图像。我知道它可以工作,因为在我为 jquery 样式添加另一个 css 文件之前它正在工作。这哪里错了?

<html xmlns=\ "http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
  <META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
  <title>Welcome to Jetty-9</title>
  <link href="css/jquery-ui-1.10.3.custom.css" rel="stylesheet">
  <link href="css/maincss.css" rel="stylesheet">
  <script type='text/javascript' src='js/jquery.js'></script>
  <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
  <script type="text/javascript">
    $(function() {
      $( "#dialog" ).dialog({
      width: 400,
      buttons: [
        {
          text: "Ok",
          click: function() {
            $( this ).dialog( "close" );
          }
        },
        {
          text: "Cancel",
          click: function() {
            $( this ).dialog( "close" );
          }
        }
      ]
    });
    });
  </script>
</head>
<body>

  <div id="dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
  </div>

</body>
</html>

最佳答案

看来您可能会遇到问题,因为:

  1. 在 CSS 文件中,您没有正确提供图像路径。 (你应该给出一个从你的 CSS 文件到 html 的相对路径)
  2. 在您的新 CSS 文件中,body{} 标签被覆盖为空。

解决方法: 尝试通过将 background-color 配置为某种颜色来检查 CSS 并进行测试。因此,您可以通过这种方式确保 CSS 正常工作并尝试其他选项。

关于javascript - CSS 未应用于页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17411685/

相关文章:

html - TD 宽度不改变 CSS HTML

html - 带有文本框 HTML 的一行一行

javascript - 如何在列表上点击进入 Sencha 的详细 View ?

javascript - 使用 ng-repeat 从对象数组中使用另一个对象的 id 属性通过 id 查找对象

javascript - 带有外部参数 Angular 的 Ajax

javascript - 无法将 html 文件链接到 jquery

javascript - React Router 无法解析参数路由

javascript - 如何将链接定向到加载到另一个页面上的 iframe 中的页面,并通过单击将其滚动到某个位置?

javascript - 如何使用 Google Closure 编译器删除未使用的 JavaScript 代码?

javascript - 添加 jQuery 验证方法时 this.optional(element) 做了什么?