我有一个 1024*768px 的图像,我想将其用作网页的背景。
我还希望这个背景覆盖整个窗口的背景,即使它调整了大小。而且......我不希望图像拉伸得尽可能少!
我已经尝试过这里的示例,除了 jquery 之外 - 因为我更喜欢仅在 css 中完成。
谢谢你!
编辑:这是链接:http://css-tricks.com/perfect-full-page-background-image/ http://css-tricks.com/perfect-full-page-background-image/
您可以尝试 backstretch 插件
这是一个单行 javascript 解决方案,只需将其(也包括 jquery)包含在标头中并将其作为示例调用:
<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/ http://srobbin.com/jquery-plugins/backstretch/
GitHub来源:https://github.com/srobbin/jquery-backstretch https://github.com/srobbin/jquery-backstretch
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)