CSS-如何设置div背景图

如何设置div背景图

给组件添加背景图控制只需要两步:

<View
            className="gifts"
            style={{
              background: `url(${baseUrl}starMove/exclusiveEntrance/card.png) no-repeat`,
              backgroundSize: '100% 100%',
            }}
          >
          <View classname="gift-lists"></View>
</View>

设置background和backgroundSize。
style={

 width:100%;
 height:100%;

}


div如何居中:

  • margin:0 auto;
  • 行内元素的垂直居中把height和line-height的值设置成一样的即可。

文本居中:
text-align:center;

https://www.cnblogs.com/demod...

评论

暂无评论