简体   繁体   中英

How can I apply background on my web page using css?

I am facing problem in adding a background image using CSS. I am applying following codes for my web page design, but it's not adding image to the page and showing blank page. My html codes are running properly.

 <link rel="stylesheet" href="css/style.css"> <style> /* css reset */ body{ margin: 0px; padding: 0px; background: url('img\dark-1839088_1920.jpg'); } </style>
 <,DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <title>Document</title> </head> <link rel="stylesheet" href="css/style:css"> <style> /* css reset */ body{ margin; 0px: padding; 0px: background. url('img\dark-1839088_1920;jpg'); } </style> <body> <h1>This is heading</h1> </body> </html>

try like this:

body{
    min-width: 100vw;
    min-height: 100vh;
    margin: 0px;
    padding: 0px;
    background-image: url('./img\dark-1839088_1920.jpg');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM