vue2:关于页面布局-行内列间间隔的调整

59 篇文章 ¥19.90 ¥99.00

如下图三行

有些控件之间需要有间隔,表示虽是同一行,但是相互之间并没有关系;

有些控件之间没有间隔,表示互相关联。

1、同行没有关系,需要有间隔的列

每一个el-col中添加一个el-form-item即可,每个el-form-item之间会有间隔

<el-col :lg="12" :sm="24">
   <el-form-item  label="相关研发需求:" prop="requirementUnid">
      <!--添加控件-->
      <el-select style="width: 100%"/>    
   </el-form-item>
</el-col>
<el-col :lg="12" :sm="24">            
   <el-form-item  label="所属模块:" prop="moduleUnid">
        <!--添加控件-->
        <el-cascader></el-cascader>
    </el-form-item>            
</el-col>

2、相互之间没有间隔,且第二个控件不需要额

uniapp 以下代码 内置浏览器样式运行到手机上样式有偏差 小车距离不一致<template> <view class="wapper"> <!-- <view class="bg-image"></view> --> <image class="bg-image" src="/static/home/bus/bg-image.png" mode="widthFix" style="width: 100%;" /> <!-- 自定义导航栏 --> <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }"> <view class="navbar-content"> <!-- 左侧返回按钮 --> <view class="back-btn" @click="handleBack"> <image src="/static/home/bus/back-icon.png" mode="aspectFit" style="width: 48rpx;height: 48rpx;" /> </view> <!--标题 --> <text class="title">{{busLineBase.name}}</text> </view> </view> <view class="wapper-content" :style="{ paddingTop: statusBarHeight +50 + 'px' }"> <view class="line_info"> <view class="site"> <text class="from">{{busLineBase.startSn}}</text> <view class="arrow"> <text class="to">{{busLineBase.endSn}}</text> </view> </view> <view class="tit"> <view class="time_s"> <text class="time-text">{{busLineBase.firstTime}}</text> </view> <view class="time_e"> <text class="time-text">{{busLineBase.lastTime}}</text> </view> <text class="price">票价: {{busLineBase.price}}</text> </view> </view> <view class="distance-class"> <view class="station"> <view class="station-title"> <view class="station-name">候车站</view> <view class="station-content"> <view class="active">动漫大厦</view> <view class="underline"></view> </view> </view> </view> <view class="distance"> <view class="time"> <text class="time_title" v-if="haveBus">12分钟</text> <text v-else>暂无车辆时</text> </view> <text class="arr">5站/2.4km</text> </view> </view> </view> <view class="site_list"> <scroll-view class="wapper_sitelist" scroll-x="true"> <view v-for="(item, index) in stateBus"> <div class="bus_road" :style="{marginLeft:item.order*48+'px'}"></div> </view> <view class="road"> <view class='part' v-for="(item, index) in siteList" @click="showActive(index, item.siteName)"> <view class='name'> <view> <view class="dot_p" :class="{'dot_p_show': ind === index}"></view> <view class='dot_r' v-if="index!=siteList.length-1"></view> </view> <view class='dot_d' :class="{'dot_d_show': ind === index}"></view> <text class='text' :class="{'text_show': ind === index}"> {{index +1}} <text class="text-dir"> {{item.sn}} </text> </text> </view> </view> </view> </scroll-view> </view> </view> </template> <script> import { getRealTimeBusLine } from '@/request/bus.js' export default { data() { return { ind: 5, siteId: "", lineName: "二号线", siteName: "动漫园站", siteList: [], busLineBase: [], stateBus: [], time_s: '', time_e: '', from: '', busPosition: [0, 5, 11], to: '', isActive: false, lineId: '', siteNum: '0', haveBus: true, // 保留原有数据项... } }, onLoad(options) { // 获取路由参数 const { statusBarHeight } = uni.getSystemInfoSync() this.statusBarHeight = statusBarHeight this.lineId = options.lineId this.lat = options.lat this.lng = options.lng this.getLineDetail() // 使用uni-app地图API // this.loadLineInfo() }, methods: { async getLineDetail() { var res = await getRealTimeBusLine({ lineId: this.lineId, lat: this.lat, lng: this.lng }) if (res.code == 0) { console.log(res) this.siteList = res.data.busInfStop this.busLineBase = res.data.busLineBase this.stateBus = res.data.stateBus this.ind = res.data.targetOrder } }, showActive(index, siteName) { this.ind = index this.text = siteName var TF = false for (let i = 0; i <= this.busPosition.length; i++) { if (index + 1 > this.busPosition[i]) { // this.haveBus = true this.siteNum = index + 1 - this.busPosition[i] TF = true } } if (TF === false) { // this.haveBus = false } }, handleBack() { uni.navigateBack() }, async loadLineInfo() { try { // 使用uni-app请求API const res = await uni.request({ url: `https://restapi.amap.com/v3/bus/linename`, data: { key: 'cd0bbe150380e1263de209abf425745b', city: '天津', keywords: this.lineName, extensions: 'all' } }) if (res.data.status === '1') { this.processLineData(res.data.lineinfo[0]) } } catch (e) { console.error('公交线路加载失败', e) } }, processLineData(tips) { // 数据处理逻辑(与Vue版相同) this.from = tips.start_stop + '-' this.to = tips.end_stop this.lineId = tips.id // 其他数据处理... }, // 保留showActivechangeDirect方法... } } </script> <style> page { background-color: #f5f5f5; } </style> <style scoped> .bg-image { position: absolute; } .custom-navbar { position: fixed; top: 0; left: 0; width: 100%; z-index: 1000; /* 自定义背景色 */ /* 自定义阴影 */ } .navbar-content { height: 44px; /* 标准导航栏高度 */ display: flex; align-items: center; padding: 0 15px; } .title { flex: 1; text-align: center; font-size: 17px; font-weight: bold; color: #333; /* 标题颜色 */ } .back-btn { width: 24px; height: 24px; } .right-area { width: 40px; text-align: right; } .info_wapper { height: 156px; /* background: #36A3F9; */ /* background: url(@/static/home/bus/detail-bg.png) left no-repeat; */ padding: 15px; color: black; position: absolute; z-index: 9; width: 100%; } .line_info { position: relative; /* display: flex; */ } .site { font-size: 32rpx; color: black; margin-bottom: 10px; text-align: left; display: flex; margin-left: 30px; } .from { /* padding-left: 52rpx; */ color: black; } .arrow { background: url(@/static/home/bus/single.png) left no-repeat; background-size: 14px 5px; margin-left: 10px; color: black; } .to { padding-left: 26px; color: black; } .time_s { background: url(@/static/home/bus/start.png) left no-repeat; background-size: 18px 18px; justify-self: baseline; } .time_e { background: url(@/static/home/bus/end.png) left no-repeat; background-size: 18px 18px; margin-left: 15px; } .price { margin-left: 15px; } .tit { color: #fff; font-size: 26rpx; /* padding-left: 52rpx; */ margin-bottom: 10px; height: 21px; color: #333; display: flex; align-items: baseline; margin-left: 30px; } .distance-class { border-radius: 15px; /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background: url(@/static/home/bus/distance-bg.png) center no-repeat; background-size: cover; height: 160px; position: absolute; z-index: 999; left: 20px; right: 20px; } .distance { color: #B7BABB; line-height: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 99; /* align-items: baseline; */ } .time { color: aquamarine; } .station { margin-left: 20px; color: #353738; padding: 10px; } .station-title { display: flex; align-items: baseline; } .station-name { margin-right: 15px; } .station-content { padding-top: 10px; /* padding-left: 20rpx; */ position: relative; /* padding-right: 50rpx; */ /* 确保文字在下划线上方 */ z-index: 2; justify-content: center; display: flex; align-items: center; /* 文字在上层 */ } .underline { position: absolute; bottom: 2px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ border-radius: 3px; z-index: -1; width: 80%; align-items: center; justify-content: center; display: flex; /* margin-left: 30rpx; */ /* width: 60rpx; */ /* 下划线在文字下方 */ } .active { color: black; /* 激活状态文字颜色 */ font-weight: bold; /* font-size: 36rpx; */ } .time { float: left; width: 40%; font-size: 26rpx; /* height: 130rpx; */ line-height: 40px; } .time { font-size: 36rpx; color: #353738; } .time-text { margin-left: 25px; } .time_title { color: rgb(14, 170, 112); font-weight: bold; } .arr { float: left; /* width: 20%; */ font-size: 30rpx; color: rgb(14, 170, 112); } .site_list { /* margin: 15px; */ /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); */ background-color: white; border-radius: 15px; margin-top: 150px; padding-left: 15px; padding-right: 15px; padding-top: 15px; padding-bottom: 10px; background: url(@/static/home/bus/site-bg.png) center no-repeat; position: absolute; z-index: 999; left: 20px; right: 20px; background-size: cover; /* 让背景图片覆盖整个视口 */ } .site_list .wapper_sitelist { width: 100%; overflow-x: scroll; position: relative; -webkit-overflow-scrolling: touch; display: flex; } .bus_road { background: url(@/static/home/bus/bus.png) no-repeat center; background-size: 28px 28px; width: 28px; height: 14px; position: absolute; z-index: 1; margin-top: 4px; left: 14px; } .road { display: flex; } .wapper_sitelist::-webkit-scrollbar { display: none; } /deep/::-webkit-scrollbar { display: none; width: 0; height: 0; } .part { padding: 10px; display: flex; flex-direction: row; text-align: center; justify-content: center; } .site_list .dot_r { margin-top: 25px; position: absolute; top: 3px; height: 3px; background: linear-gradient(to right, rgb(110, 207, 169), rgb(110, 224, 176)); /* 下划线颜色 */ border-radius: 3rpx; z-index: 1; width: 48px; align-items: center; justify-content: center; display: flex; } .site_list .name { margin-top: 28px; display: flex; flex-direction: column; align-items: center; } .site_list .text { display: flex; text-align: center; margin-left: 5px; } .site_list .text_show { display: flex; text-align: center; margin-left: 5px; color: rgb(14, 170, 112); font-weight: bold; } .site_list .dot_show { background: url(@/static/home/bus/position_red.png) no-repeat center; background-size: 14px 18px; } .site_list .dot_d_show { border-radius: 50%; width: 16px; height: 16px; background-color: rgba(110, 207, 169, 0.5); position: absolute; z-index: 99999; top: 21px; margin-left: 8px; display: flex; align-items: center; justify-content: center; } .road-class { display: flex; } .dot_p { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(110, 207, 169); position: absolute; z-index: 99999; top: 25px; display: flex; align-items: center; justify-content: center; /* margin-left: 10rpx; */ } .dot_p_show { border-radius: 50%; width: 8px; height: 8px; background-color: rgb(14, 170, 112); position: absolute; z-index: 99999; top: 25px; display: flex; align-items: center; justify-content: center; } .text-dir{ margin-top: 5px; writing-mode: vertical-rl; letter-spacing: 3px; } </style>
07-02
<script setup lang="ts"> definePage({ name: 'member', style: { navigationBarTitleText: '会员', navigationStyle: 'custom', disableScroll: true }, }) // 会员协议 const memberAgreementCheckBox = ref(false) // 会员套餐 const memberPackage = ref([ { id: 1, desc: '超维创作引擎', type: 'SVIP 年卡', select: true, amount: '16888', status: true }, { id: 2, desc: '量子创意工坊', type: 'SVIP 月卡', select: false, amount: '6888', status: false }, { id: 3, desc: '量子创意工坊', type: 'SVIP 周卡', select: false, amount: '1888', status: false } ]) // 返回上一页 const onClickLeft = () => { uni.navigateBack() } const activeMember = () => { if (memberAgreementCheckBox.value) { useGlobalToast().success('恭喜您,会员开通成功!') } else { useGlobalToast().info('请先阅读并同意会员协议!') } } </script> <template> <view class="member-page-container"> <wd-navbar custom-class="ai-navbar" fixed custom-style="background-color: transparent !important; height: 140rpx !important;" safeAreaInsetTop> <template #left> <view class="left-button" @click="onClickLeft"> <wd-icon name="arrow-left1" size="22px"></wd-icon> </view> </template> <template #title> <view class="title-box"> <view class="title-text"></view> </view> </template> </wd-navbar> <view class="container"> <text class="member-page-text">开通 <text class="member-page-vip-text">SVIP</text></text> <text class="member-page-text">畅想 AI  全功能</text> <text class="member-page-desc">新用户享受超低折扣</text> <scroll-view class="member-package-scroll" :scroll-x="true" :show-scrollbar="false"> <view class="member-package-box"> <view class="member-package" v-for="item in memberPackage" :key="item.id"> <text class="desc">{{ item.desc }}</text> <text class="vip">{{ item.type }}</text> <text class="text">开会员,天天送云点</text> <view><text class="select" v-if="item.select">80% 选择</text></view> <text class="amount">$<text class="amount-text"> {{ item.amount }}</text></text> </view> </view> </scroll-view> </view> <view class="fixed-footer"> <view class="activate-box"> <wd-button type="info" plain @click="activeMember" custom-class="activate-member"> <text class="activate-text">立即开通</text> </wd-button> <view class="member-desc"> <wd-checkbox v-model="memberAgreementCheckBox" @click="memberAgreementCheckBox = !memberAgreementCheckBox" shape="square" custom-style="background-color: transparent !important;"> <text class="login-clause"> 勾选即代表您已阅读并同意 <text class="member-agreement" @click.stop="useGlobalToast().success('会员协议')"> 《会员协议》 </text> </text> </wd-checkbox> </view> </view> </view> </view> </template> <style scoped lang="scss"> .member-page-container { display: flex; flex-direction: column; height: 100vh; } .left-button { margin: 20rpx; border-radius: 50px; height: 80rpx; width: 80rpx; background-color: rgba(172, 172, 172, 0.13); display: flex; align-items: center; justify-content: center; } .title-box { display: flex; height: 100%; align-items: center; justify-content: center; } .title-text { font-size: 32rpx; font-weight: 600; /* 设置字体透明 */ color: transparent; /* 设置线性渐变,从红色渐变到蓝色 */ background-image: linear-gradient(45deg, rgba(0, 149, 255, 0.6), rgba(31, 248, 132, 0.6)); /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */ -webkit-background-clip: text; /* 非Webkit内核浏览器需要使用标准前缀 */ background-clip: text; /* 把当前元素设置为行内块,以便能够应用背景 */ display: inline-block; } .container { flex: 1; padding-top: calc(140rpx + 54px); display: flex; flex-direction: column; width: 100%; overflow: hidden; /* 防止溢出滚动条 */ margin: 0 45rpx; } .member-page-text { font-size: 58rpx; font-weight: 900; /* 设置字体透明 */ color: transparent; /* 设置线性渐变,从红色渐变到蓝色 */ background-image: linear-gradient(45deg, rgba(255, 89, 239, 0.69), rgba(31, 241, 248, 0.82)); /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */ -webkit-background-clip: text; /* 非Webkit内核浏览器需要使用标准前缀 */ background-clip: text; /* 把当前元素设置为行内块,以便能够应用背景 */ display: inline-block; } .member-page-vip-text { font-size: 58rpx; border-radius: 20rpx; padding: 0 20rpx; color: #b559ff; background-image: linear-gradient(90deg, rgba(240, 38, 255, 0.48), rgba(255, 42, 195, 0.49)); } .member-page-desc { font-size: 28rpx; color: rgba(149, 149, 149, 0.82); } .member-package-scroll { width: 100%; } .member-package-box { margin: 38rpx 90rpx 38rpx 0; display: flex; width: 100%; height: 450rpx; display: flex; flex-direction: row; } .member-package { display: flex; flex: none; flex-direction: column; background-image: linear-gradient(45deg, rgba(70, 244, 190, 0.79), rgba(232, 121, 171, 0.85)); border-radius: 38rpx; height: 330rpx; width: 330rpx; margin-right: 45rpx; padding: 38rpx; .desc { color: rgba(255, 255, 255, 0.8); font-size: 38rpx; } .vip { color: rgba(213, 10, 232, 0.8); font-size: 68rpx; } .text { color: rgba(255, 255, 255, 0.8); font-size: 23rpx; margin: 10rpx 0; } .select { margin: 12rpx 0; padding: 5rpx 25rpx 5rpx 15rpx; color: rgba(182, 34, 34, 0.94); background-color: rgba(213, 83, 68, 0.61); font-size: 25rpx; border-radius: 0 0 25rpx 0; } .amount { flex: 1; display: flex; align-items: flex-end; justify-content: flex-end; font-size: 38rpx; color: rgba(232, 33, 246, 0.92); } .amount-text { font-size: 68rpx; } } .fixed-footer { height: 220rpx; background-color: transparent; display: flex; align-items: center; justify-content: center; padding-top: 30rpx; } .activate-box { width: 80%; margin: 0 0 env(safe-area-inset-bottom) 0; :deep() { .activate-member { font-size: 35rpx !important; font-weight: 600 !important; width: 100%; height: 88rpx !important; background-image: linear-gradient(45deg, rgba(62, 233, 255, 0.5), rgba(217, 39, 255, 0.5)) !important; border: rgba(215, 55, 232, 0.49) 3rpx solid !important; } } } .member-desc { display: flex; justify-content: center; margin-top: 20rpx; } .activate-text { /* 设置字体透明 */ color: transparent; /* 设置线性渐变,从红色渐变到蓝色 */ background-image: linear-gradient(45deg, rgba(255, 36, 237, 0.87), rgba(31, 241, 248, 0.82)); /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */ -webkit-background-clip: text; /* 非Webkit内核浏览器需要使用标准前缀 */ background-clip: text; /* 把当前元素设置为行内块,以便能够应用背景 */ display: inline-block; } .member-agreement { color: #007aff; } </style> 中 的member-package滚动不到头
最新发布
11-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值