saturngod
saturngod

Reputation: 24967

HTML full background image is not working with bootstrap

Current code is

<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>

It's showing full screen background image. However, I tried to add bootstrap css, background image is gone.

<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>

I would like to know why and how can I fix that ?

Upvotes: 0

Views: 43

Answers (2)

saturngod
saturngod

Reputation: 24967

It's working after adding

body {
 background: none;
}

Upvotes: 0

GuiguiWeb
GuiguiWeb

Reputation: 53

Use body not html for 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>

Upvotes: 2

Related Questions