css - 如何在放大和缩小时拉伸(stretch)背景图像?

标签 css

#leftHalf {
  background:url("img/header/CRC_Website_TopBannerLeftStretch.jpg") repeat scroll 0 0 / 38% 100% hsla(0, 0%, 0%, 0) ;   
   width: 50%;
   position: absolute;
   left: 0px;
   height: 190px;
   z-index:-1;
}
#rightHalf {
   background: url("img/header/CRC_Website_TopBannerRightStretch.jpg");
   width: 41.5%;
   position: absolute;
   right: 0px;
   height: 190px;
   z-index:-1;
   top:0;
}

现在,当我放大时背景图像会重复。但我想在放大和缩小时拉伸(stretch)左右顶部横幅图像。

提前致谢。

最佳答案

试试这个:

 background-image:url(../images/header-bannerbg.png);
 background-position:fixed;
 background-repeat:no-repeat;
 height:580px;
 -webkit-background-size: 100% 100%;
 -moz-background-size: 100% 100%;
 -o-background-size: 100% 100%;
 background-size: 100% 100%;

关于css - 如何在放大和缩小时拉伸(stretch)背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24162510/

相关文章:

html - 如何在文本框中添加垂直线以分隔元素

javascript - jquery 动画速度没有改变

javascript - 如何在每个循环中重复使用不同颜色的 svg 动画?

html - 使用 Flexbox,如何以编程方式移动 div?

css - 左/右对齐按钮和固定宽度

javascript - 点击图片不改变

html - 为什么我的 span 元素在 IE9 中看起来很糟糕?

html - Windows Phone 中 <span> 标签前出现的缩进

JQuery - 如果 div 文本包含存储在数组中的相同文本,则将该文本包装在新的 div 中

javascript - .show() 上的 jQuery 与 LinkedIn : content is not displayed