CSS-如何拉伸和自动调整背景图像的大小 [英] css - how to stretch and auto-resize background image

查看:149
本文介绍了CSS-如何拉伸和自动调整背景图像的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我的背景图片延伸到整个页面,但是到目前为止,我已经做到了:

I'm trying to get my background image to stretch across the entire page, but so far i have this:

这是我要在浏览器窗口中拉伸的图片:

This is the picture i want stretched across the browser window:

我的外部CSS包含以下代码:

My external CSS contains the code below:

hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("mybackground.jpg")} 

谁能告诉我如何编辑CSS文件来解决我的问题?

Can anyone tell me how I can edit the CSS file to fix my problem?

推荐答案

您可以使用:

background-size: cover;

但是请记住此浏览器支持的浏览器.例如,这在IE8及以下版本中将不起作用.

However please bear in mind which browsers this supports. For example, this won't work in IE8 and below.

这篇关于CSS-如何拉伸和自动调整背景图像的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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