开发者

How to center a user's view using javascript

开发者 https://www.devze.com 2023-03-08 17:35 出处:网络
I have a webpage with a background image that extends (in some resolutions) beyond the width of the browser\'s window.

I have a webpage with a background image that extends (in some resolutions) beyond the width of the browser's window.

The contents of the webpage in question are centered, relative to the background image, and so I would like that the visitors to the webpage would have their view horizontally centered aswell.

Is that possible? If not, how would I 开发者_如何学Gogo with dynamically cropping the background image, to fit the window size of the viewer?


Modify the css:

Goto the body{} class and modify it as:

body
{
background: url('path-to-ur-image/image.jpg') top no-repeat;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消