2017-06-03 63 views
0

當前代碼工作是HTML全背景畫面沒有引導

<html><head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <title>Full Page Background Image</title> 

    <style> 
     * { margin: 0; padding: 0; } 

     html { 
      background: url(./images/bg.jpg) no-repeat center center fixed !important; 
      -webkit-background-size: cover; 
      -moz-background-size: cover; 
      -o-background-size: cover; 
      background-size: cover; 
     } 


    </style> 
</head> 

<body> 

</body> 
</html> 

它顯示全屏幕的背景圖像。但是,我試圖添加引導CSS,背景圖像消失了。

<html><head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <title>Full Page Background Image</title> 
    <link href="./bootstrap/css/bootstrap.css" rel="stylesheet"> 
    <script src="./js/jquery.min.js"></script> 
    <script src="./bootstrap/js/bootstrap.min.js"></script> 
    <style> 
     * { margin: 0; padding: 0; } 

     html { 
      background: url(./images/bg.jpg) no-repeat center center fixed; 
      -webkit-background-size: cover ; 
      -moz-background-size: cover ; 
      -o-background-size: cover ; 
      background-size: cover; 
     } 


    </style> 
</head> 

<body> 

</body> 
</html> 

我想知道爲什麼以及如何解決這個問題?

+0

如果刪除'fixed'後? ....順便說一句,我試過,沒有問題,對我來說,在Chrome – LGSon

+0

是的,刪除引導,它的工作 – saturngod

+1

對我來說,它與引導工作.... https://jsfiddle.net/tobLtrc5/ – LGSon

回答

2

使用bodyhtml對CSS

<html><head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <title>Full Page Background Image</title> 
    <link href="./bootstrap/css/bootstrap.css" rel="stylesheet"> 
    <script src="./js/jquery.min.js"></script> 
    <script src="./bootstrap/js/bootstrap.min.js"></script> 
    <style> 
     * { margin: 0; padding: 0; } 

     body { 
      background: url(./images/bg.jpg) no-repeat center center fixed; 
      -webkit-background-size: cover ; 
      -moz-background-size: cover ; 
      -o-background-size: cover ; 
      background-size: cover; 
     } 


    </style> 
</head> 

<body> 

</body> 
</html> 
+0

是的:https: //codepen.io/anon/pen/EXxvjo – GuiguiWeb

+1

我看到了......仍然沒有解決任何問題,因爲它已經與'html'一起工作了,因此改變爲'body':https://jsfiddle.net/tobLtrc5/ – LGSon

0

它的工作將

body { 
background: none; 
} 
+0

由於我的小提琴演示工作原樣,在您的本地副本'bootstrap.css'中必須有一些東西,它具有設置在主體上的背景,其他任何東西都沒有意義 – LGSon