Bootstrap

微信小程序引入背景图的三种方法

一。微信小程序引入背景图的三种方法

1.直接在标签里加上style样式,加上背景图:

<view style="background:url('../../img/p.png')"></view>
2.如果想使用外部样式表引入的话,直接使用background会报渲染层错误,可以将图片上传到服务器,然后在使用background

3.直接使用image标签引用

二。微信小程序选择引入背景图片位置

<view class="dao_bor " style="background:url('../../images/p.png')-90px -90px no-repeat"></view>

三。CSS3 背景图片显示尺寸(放大/缩小背景图)(background-size) (背景适配 自适应)
    <style>
        .box {
            width: 500px;
            height: 500px;
            margin: 100px auto;
            border: 1px solid #000;
            background: url("p.png") no-repeat;
 
            /* 背景图片显示尺寸(放大/缩小背景图) */
            background-size: 200px 200px;  /* 通过像素设置 */
            background-size: 50% 50%;    /* 通过百分比设置 */
            background-siz

;