CSS被舒展的背景图象 [英] CSS Stretched Background Image

查看:118
本文介绍了CSS被舒展的背景图象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大图像用作一个页面的 background-image 。我想要的是图像的高度将被拉伸以填充页面的高度。

I have a large image to be use as a background-image of a page. What I want is that the height of the image will be stretched to fill the height of the page. It should be centered also.

background: black url("/image/background.jpg") no-repeat fixed center;


推荐答案

background-size:cover 会在现代浏览器中执行操作 - 请参阅mozilla的文档

background-size: cover will do the trick in modern browsers - see mozilla's documentation for more details.

对于老版本的浏览器(尤其是旧版本的IE),我已经在jQuery插件上取得了很大的成功,例如这一个来模拟行为。

For older browsers (particularly older versions of IE), I've had a lot of success with jQuery plugins like this one to emulate the behaviour.

这篇关于CSS被舒展的背景图象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆