微信小程式 - 相對定位和絕對定位 - 相對路徑和絕對路徑
阿新 • • 發佈:2018-12-05
微信小程式 - 相對定位和絕對定位
相對定位relative,絕對定位absolute
相對定位:元素是相對自身進行定位,參照物是自己.
絕對定位:元素是相對離它最近的一個父級元素進行定位.
相對定位:relative
position:relative; /*相對定位*/
left:50rpx; /*相對於自己往右偏離50*/
top:50rpx; /*相對於自己往下偏離50*/
絕對定位:absolute
position: absolute;
left: 50rpx;
top: 50rpx;
效果:
.bei { width: 100rpx; height: 100rpx; flex: 1; border-radius: 50%; background-color: #00b2ee; margin: 30rpx auto 0; } .bei image { width: 90rpx; height: 90rpx; margin-top: 5rpx; } .text { font-size: 30rpx; color: #fff; position: relative; top: 20rpx; }
.wxml
<view class='bei'>
<image src='/images/Attendance-early.png' style="display: {{none}};"></image>
<text class='text'>{{zao}}</text>
</view>
position【定位屬性:static,relative,absolute,fixed,inherit,-ms-page,initial,unset】
相對路徑和絕對路徑
絕對路徑: 以“/”開頭代表根目錄
相對路徑:
../../a/index
或者:
a/index
達叔小生:往後餘生,唯獨有你
You and me, we are family !
90後帥氣小夥,良好的開發習慣;獨立思考的能力;主動並且善於溝通
簡書部落格: 達叔小生
https://www.jianshu.com/u/c785ece603d1
結語
- 下面我將繼續對 其他知識 深入講解 ,有興趣可以繼續關注
- 小禮物走一走 or 點贊