最好的办法背景盖跨浏览器 [英] Best way to background cover cross browser
问题描述
我有,我想作为网页背景使用1024 * 768px的形象。
I have a 1024*768px image that I want to use as a background for a webpage.
我也想这样的背景下,以覆盖整个窗口的背景,即使它的大小。而且....我wan't的形象至少伸展越好!
I also want this background to cover the background of the entire window, even when it's resized. And.... I wan't the image to stretch least as possible!
我试过这里的例子,除了jQuery的 - 一。因为我想更好如果只在CSS做
I've tried the examples here, except the jquery one - since I'd like it better if only done in css.
谢谢!
编辑:这里的链接: http://css-tricks.com /完美-整版背景图像/
推荐答案
您可以尝试直道插件
这是一个一行JavaScript的解决方案,只是它包含(也jQuery的)在你的头,并调用它为例:
It is a one line javascript solution, just include it (also jquery) in your headers and call it as the example:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="jquery.backstretch.min.js"></script>
<script>
// To attach Backstrech as the body's background
$.backstretch("path/to/image.jpg");
</script>
官方页面:
http://srobbin.com/jquery-plugins/backstretch/
Github的来源:
https://github.com/srobbin/jquery-backstretch
Github source: https://github.com/srobbin/jquery-backstretch
这篇关于最好的办法背景盖跨浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!