CSS未应用于页面

Agg*_*Dev 0 html javascript css jquery 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>
Run Code Online (Sandbox Code Playgroud)

小智 5

看来你可能会面临问题,因为:

  1. 在CSS文件中,您未正确提供的图像路径.(您应该从CSS文件中提供相对路径而不是html)
  2. 在新的CSS文件中,body{}标记被覆盖为空.

解决方法:尝试通过配置background-color某种颜色来检查CSS 并测试它.所以这样你可以确保CSS工作正常并尝试其他选项.