CSS width: 100%;

  box-sizing: border-box;

body::before {
 position: fixed;
 top: 0;
 left: 0;
 z-index: -1;
 height: 100%;
 width: 100%;
 background-image: url(https://c4.wallpaperflare.com/wallpaper/274/552/5/kittens-many-photoshop-wallpaper-preview.jpg);

‘width:100%’ in this code Why doesn’t the image load in the background without it? I really don’t understand here

1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

What the MDN docs say about fixed positioning:


“The element is removed from the normal document flow, and no space is created for the element in the page layout.”

So you have to add a width and height to create the space for the element when using fixed positioning.

ohh thank you so much!!