[英]Making an image completely fill a div without tiling
我是html / css的新手,我正在为妈妈编码一个网站。 (此处为实时示例: http : //jleblanc.pancakeapps.com/core.html ),为了我的生命,我无法在底部获得照片以填充各自的div! 你们有想法吗? 我不在乎图像是否被剪切。
的HTML
<div class="one">
<article>
</article>
</div>
<div class="two">
<article>
</article>
</div>
<div class="three">
<article>
</article>
</div>
的CSS
.one {
background:linear-gradient(rgba(255,0,0,0.45),rgba(255,0,0,0.45)),url(http://dash.ga.co/assets/firstcourse.jpg)
}
.two {
background:linear-gradient(rgba(0,255,0,0.45),rgba(0,255,0,0.45)),url(http://dash.ga.co/assets/secondcourse.jpg)
}
.three {
background:linear-gradient(rgba(0,0,255,0.45),rgba(0,0,255,0.45)),url(http://dash.ga.co/assets/dessertcourse.jpg)
}
您正在使用CSS background
属性将图像设置为div的背景。 尝试更改background-size
属性:
.one {
background-size: cover;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.