Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

小程序设置这个背景图片为什么没有铺满呢?

给的UI背景图没有错 设置背景图片后左边总是有空隙 背景图片为什么没有铺满呢?这是怎么回事?
可以复制我的代码直接运行
image

<view class="index">
    <view class="top">
    </view>
</view>
.index{
  width: 100%;
  height: 100vh;
}
.top{
  background-color: red;
  width: 750rpx;
  height: 248rpx;
  background-repeat:no-repeat; 
  background-size:cover;
  -moz-background-size:100% 100%;
  display: flex;
  flex-direction: column;
  background-image: url(http://aigou-file.obs.cn-south-1.myhuaweicloud.com/images/5/2020/12/GI8zYagF88SDqSqb1Ug1WSDNTYOUzw.png);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

.top{ background-position: center;}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...