[英]How to make background image to be displayed fully and to cover the full size
我有一个标题div,我想完全覆盖一个背景图片。 我希望图像能完整显示,所以没有裁剪。 但是,它似乎正在拉伸图像并对其进行裁剪。
CSS:
..header{
border-top-left-radius:5px;
border-top-right-radius: 5px;
max-width: 600px;
width:100%;
height: auto;
min-height: 200px;
background: url("img/bg-abstract.jpg") no-repeat fixed;
background-position: left top;
background-size: 100%;
position: relative;
background-attachment: fixed;
background-repeat: no-repeat;
}
您需要的是
background-size:cover
background-size: cover
也请尝试使用%
而不是px
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.