简体   繁体   English

背景重复不适用于绝对位置

[英]Background Repeat not working with absolute position

An image is used as background image which is absolute positioned it has repeat-x property but not working 图像用作absolute positioned背景图像,具有repeat-x属性,但不起作用

 <div>
    <div class="background-image">
    </div>
 </div>


 .background-image{
       position:absolute;
       background-image : url(...);
       background-repeat: repeat-x;
  }

Is there any solution? 有什么解决办法吗?

you have to set the height of .background-image class and also set the width of container div. 您必须设置.background-image类的高度,还必须设置容器div的宽度。

Hopefully this ll helpful 希望这会有所帮助

 div { margin: 0 auto; width: 600px; background-color: #ccc; } .background-image { position: absolute; background-image: url(https://cdn4.iconfinder.com/data/icons/miu/22/circle-social_facebook_outline_stroke-128.png); background-repeat: repeat-x; height: 130px; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM