微信小程序css设置本地背景图片
<style>
div{
width: 500px;
height: 500px;
}
.box1{
background-image: url(../../image/alltest_bag.jpg);
}
</style>
<div class="box1"></div>
报错:
<view class="container">
<image class="bgImg" src="/images/xxx.png"></image>
<other-widget class="other-widget"></other-widget> <!-- other widget希望是放在背景图片之上的 -->
</view>
wxss:
.container{
position: relative;
}
.other-widget{
position: absolute;
}
如果不采用定位的方法,other-widget就会按照块级元素排列在image的下边,但是如果我们采用绝对定位使other-widget脱离文档流,它就会相对于container进行定位,也就实现了在背景图片之上的效果。
上一篇:
uniapp开发微信小程序-2.页面制作
下一篇:
基于微信小程序的校园论坛系统开发过程
