Ola Mohey Ola Mohey - 2 months ago 10
CSS Question

How to set background to div

I tried to set image in background of a div but disappeared! I want the background image covers all page, thanks.

<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
div {
width:100%;
height: 100%;
background-image: url('https://static.vecteezy.com/system/resources/previews/000/094/491/original/polygonal-texture-background-vector.jpg');
}
</style>
</head>
<body>
<div></div>
</body>
</html>

Answer

for this make parents 100% by:

html,body{width:100%;height: 100%;}