jquery – background-image:url(“images / plaid.jpg”)no-repeat;不会出现

前端之家收集整理的这篇文章主要介绍了jquery – background-image:url(“images / plaid.jpg”)no-repeat;不会出现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我似乎无法在我的任何页面上制作我的plaid.jpg背景,更不用说所有这些了,我已经尝试通过body,html,*,“home”的具体ID来选择它.什么都行不通图像为300 x 421像素.我不需要它显示漂亮,我只是希望它出现在一切背后.我的css怎么看这个? plaid.jpg图片位于我的images文件夹中与index.html文件位于同一目录中.此链接位于index.html文件的顶部.我的样式表位于名为mystyles.css的样式表文件夹中.
  1. <link rel="stylesheet" type="text/css" href="stylesheets/mystyles.css">

在我看来,我试图以可想象的方式改变我的.CSS文件.前30个谷歌搜索结果“背景图像没有显示”,但没有一个工作.我知道这可能很简单.

mystyles.css是最基本的形式,没有选择器.

  1. background-image: url("images/plaid.jpg") no-repeat;

的index.html

  1. <body>
  2. <!-- Page: home -->
  3. <div id="home"
  4. data-role="page"
  5. data-title="Home">
  6. <div data-role="header"
  7. data-position="fixed"
  8. data-theme="b">
  9. <h1>Home</h1>
  10. <a href="#info"
  11. data-icon="info"
  12. data-iconpos="notext"
  13. data-rel="dialog"
  14. class="ui-btn-right"
  15. >Info</a>
  16. </div><!-- header -->
  17. <div data-role="content">
  18.  
  19. <div data-role="controlgroup" data-theme="e">
  20. <a href="#blog"
  21. data-role="button"
  22. data-icon="arrow-r"
  23. data-theme="e"
  24. >Blog</a>
  25. <a href="#videos"
  26. data-role="button"
  27. data-icon="arrow-r"
  28. data-theme="e"
  29. >Videos</a>
  30. <a href="#photos"
  31. data-role="button"
  32. data-icon="arrow-r"
  33. data-theme="e"
  34. >Photos</a>
  35. <a href="#tweets"
  36. data-role="button"
  37. data-icon="arrow-r"
  38. data-theme="e"
  39. >Tweets</a>
  40. </div><!-- links -->
  41. </div> <!-- content -->
  42. </div><!-- page -->

这不成功

  1. body {
  2. background-image: url("/images/plaid.jpg");
  3. background-repeat: no-repeat;
  4. }

这也是我的意思

  1. <head>
  2. <Meta charset="utf-8" />
  3. <title>Mob App</title>
  4. <head>
  5. <Meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
  6.  
  7. <link rel="shortcut icon" href="images/favicon.ico" />
  8.  
  9. <!--<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />-->
  10. <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  11. <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
  12.  
  13. <script src="javascripts/myscript.js"></script>
  14. <link rel="stylesheet" type="text/css" href="stylesheets/mystyles.css" />
  15. </head>

解决方法

你要么使用:
  1. background-image: url("images/plaid.jpg");
  2. background-repeat: no-repeat;

… 要么

  1. background: transparent url("images/plaid.jpg") top left no-repeat;

……但最终没有

  1. background-image: url("images/plaid.jpg") no-repeat;

编辑:使用绝对路径JSFIDDLE进行演示(如果您在使用相对路径引用图像时遇到麻烦).

猜你在找的jQuery相关文章