Q
固定拉伸背景图片
1
A
回答
1
如果您不介意使用CSS3的background-size
属性,那么以下将添加到您的#content-wrap {
CSS语句中将获得响应的背景图像,该图像将扩展以适应容器的大小。
#content-wrap {
height: 1000px;
background: #ccc;
color: #fff;
/* Added CSS */
display: block;
max-width: 100%;
clear: both;
background: transparent url("http://placekitten.com/900/900") top right no-repeat;
background-size: cover;
}
这是你的jsfiddle的更新版本,我添加的CSS和一些可爱的placekittens: http://jsfiddle.net/kztGj/22/
的缺点这个是当然的,它不会在Internet Explorer < 9,Firefox 3.6的工作,或任何不支持CSS3的浏览器。但是,接下来你需要一个响应式图像,因此你会很难找到一个支持旧版浏览器的优雅解决方案。
有关background-size
财产及其用途的更多信息,我建议您查看this article,其相当丰富。
+0
这是一个很棒的JS,它可以为你带来这个IE - https://github.com/louisremi/jquery.backgroundSize.js – Brian 2012-09-05 01:30:38
0
在你的图像,添加CSS这样
.custom-image {
width:100%;
}
和你HTML
<div>
<img src="" class="custom-image" />
</div>
相关问题
- 1. 拉伸背景图片
- 2. Android背景图片拉伸
- 3. 背景图片拉伸
- 4. CSS拉伸背景图片
- 5. CSS - 背景图片拉伸
- 6. 布局:拉伸的背景图片
- 7. WatchOS背景图片拉伸下表
- 8. 背景图片拉伸问题
- 9. 按钮背景图片拉伸
- 10. 拉伸iOS背景图像
- 11. 背景图像拉伸
- 12. 拉伸背景图像
- 13. JS拉伸背景图像
- 14. UITableViewController背景图像拉伸
- 15. TextView背景拉伸
- 16. UITableViewCell背景拉伸
- 17. jquery拉伸背景图片幻灯片与html和控件
- 18. FullPage JS固定背景图片
- 19. 的UITableViewController - 固定背景图片
- 20. 位置:固定有背景图片?
- 21. 2背景拉伸1背景
- 22. 无背景附件缩放背景图片:固定?
- 23. CSS背景图像拉伸与背景图像属性
- 24. 背景图像作为固定背景
- 25. 拉伸图像作为背景
- 26. 拉伸在CSS背景图像
- 27. 防止拉伸按钮背景图像
- 28. 垂直拉伸背景图像
- 29. UIButton背景图像拉伸Xcode iOS
- 30. 的ImageButton拉伸背景图像
你的意思是,作为背景图像。有这个http://jsfiddle.net/kztGj/22/? – Jeemusu 2012-08-15 04:06:58
@Jeemusu是作为背景图片 - 您的示例非常接近,因为图片无法具有固定高度,因为内容会填充页面,因此会增加页面高度。 – Filth 2012-08-15 04:09:22
如果删除高度,如第22次迭代jsfiddle.net/kztGj/22?等等,你是指固定高度?容器上的固定高度为300px? – Jeemusu 2012-08-15 04:09:56