Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do not move background image on Window resize, keep it static

Tags:

html

css

When I resize my window the background image also moves and gets resized, I dont want it to get resize, i want it to remain static. I am really confused how to keep my background static. If I set the width in pixels, then it remains static but that wont be good option as depending on different screen sizes

body {
    background-color: #000000;
    margin: 0 auto;
    width: 100%;
}

#container {
    background: url("url") no-repeat scroll center top transparent;
    width: 100%;
}

The code is like:

<body>
<div id="container">
</div>
</body>
like image 338
Deepanshu Goyal Avatar asked Feb 01 '26 22:02

Deepanshu Goyal


1 Answers

Try this code -

#container {
    background: transparent url("url") 0 0 no-repeat;
    width: 100%;
}
like image 102
Ashis Avatar answered Feb 03 '26 11:02

Ashis