#vue# #uni-app# 使用定位实现文字在图片上显示,且左右滑动附源码
思路:
(1)排版:使用弹性布局,将页面排列出来,再用v-for循环出来
(2)在最大的盒子加overflow-x: scroll; 达到左右滑动
(3)使用定位(子绝父相)让文字显示在图片上面
源码如下:
-
<template>
-
<view>
-
<!-- 挑战活动版块 -->
-
<view class="examine">
-
<view class="examine-item" v-for="(item,index) in examinelist">
-
<view class="examine-plan">
-
<image :src="item.image" mode="widthFix"></image>
-
<image :src="item.src" class="img" mode="widthFix"></image>
-
<view class="title">请输入你的名字</view>
-
<view class="start-time">请输入开始时间</view>
-
<view class="end-time">请输入结束时间</view>
-
<view class="examine-time">
-
<view class="item">
-
<view class="item-num">40</view>
-
<view class="item-min">min</view>
-
</view>
-
<view class="item-day">day 01</view>
-
</view>
-
</view>
-
</view>
-
</view>
-
</view>
-
</template>
-
<script>
-
export default {
-
data() {
-
return {
-
examinelist: [{
-
image: '/static/home/motion4.jpg',
-
src: '/static/home/3.png'
-
},
-
{
-
image: '/static/home/motion5.jpg',
-
src: '/static/home/2.png'
-
},
-
{
-
image: '/static/home/motion6.jpg',
-
src: '/static/home/3.png'
-
}
-
],
-
}
-
},
-
methods: {
-
-
-
-
}
-
}
-
</script>
-
<style lang="scss">
-
.examine {
-
overflow-x: scroll; //左右滑动
-
padding: 20upx;
-
display: flex;
-
width: 95%;
-
margin: 30upx auto;
-
.examine-item {
-
position: relative; //父盒子,相对定位
-
display: flex;
-
width: 256upx;
-
height: 383upx;
-
border-radius: 20upx;
-
margin-right: 50upx;
-
.examine-plan {
-
position: relative;
-
width: 256upx;
-
height: 383upx;
-
border-radius: 20upx;
-
.img {
-
width: 80upx;
-
position: absolute;
-
top: -20upx;
-
left: 30upx;
-
}
-
.title {//子盒子
-
position: absolute; //子盒子,绝对定位
-
top: 95upx; //顶部与父盒子的距离
-
left: 20upx; //左边与父盒子的距离
-
font-size: 28upx;
-
color: #FFFFFF;
-
}
-
.start-time {
-
position: absolute;
-
top: 156upx;
-
left: 20upx;
-
font-size: 22upx;
-
color: #FFFFFF;
-
}
-
.end-time {
-
position: absolute;
-
top: 200upx;
-
left: 20upx;
-
font-size: 22upx;
-
color: #FFFFFF;
-
}
-
.examine-time {
-
position: absolute;
-
bottom: 40upx;
-
left: 20upx;
-
display: flex;
-
width: 90%;
-
margin: auto;
-
justify-content: space-between; //子盒子左右排列
-
align-items: flex-end; //指最后一个子盒子
-
.item {
-
display: flex;
-
align-items: flex-end;
-
.item-num {
-
font-size: 40upx;
-
color: #FFFFFF;
-
}
-
.item-min {
-
font-size: 20upx;
-
color: #FFFFFF;
-
vertical-align: bottom; //文字底部与父盒子底部对齐
-
}
-
}
-
.item-day {
-
font-size: 20upx;
-
color: #FFFFFF;
-
vertical-align: bottom;
-
}
-
}
-
image {
-
width: 256upx;
-
height: 383upx;
-
border-radius: 20upx;
-
}
-
}
-
}
-
}
-
</style>
效果展示:
(左右滑动)
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhggfcgc
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13