Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS Background Shorthand property not work?

 **CSS**

Why my CSS Background Shorthand Property does not work .I have applied many processes ,But it’s not working.

      **CSS stylesheet**
        *{
            padding: 0;
            margin: 0;
        }
        .container{
            width: 800px;
            height: 800px;
            margin: 0 auto;
            border: solid 2px;
            background: red url(image/computer.png) no-repeat cover fixed;
        }
   
   **HTML code**
        <div class="container">
    
        </div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Two problems you have to fixed:

You doesn’t have the "" for the url.

You have to separately set the background-size:cover property.

Set it in the background will not work.

*Not sure if image/computer.png is a local image or an invalid image. If it is a local image, just replace the url back (I change the url to wikipedia icon for showing purpose)

*{
         padding: 0;
            margin: 0;
        }
        .container{
            width: 800px;
            height: 800px;
            margin: 0 auto;
            border: solid 2px;
            background: red url("https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/2244px-Wikipedia-logo-v2.svg.png")  0 0 no-repeat fixed;
           
        }
<div class="container">
    
        </div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading