在微信小程序开发中,常用的布局主要包括以下几种:
<view class="container">
<view class="item">Item 1view>
<view class="item">Item 2view>
<view class="item">Item 3view>
view>
.container {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.item {
flex: 1;
background-color: #f2f2f2;
padding: 10px;
}
<view class="container">
<view class="item">Item 1view>
<view class="item">Item 2view>
<view class="item">Item 3view>
view>
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.item {
background-color: #f2f2f2;
padding: 10px;
}
<view class="container">
<view class="item">Item 1view>
<view class="item">Item 2view>
<view class="item">Item 3view>
view>
.container {
overflow: hidden; /* 清除浮动 */
}
.item {
float: left;
width: 33.33%;
background-color: #f2f2f2;
padding: 10px;
}
<view class="container">
<view class="item">Item 1view>
<view class="item">Item 2view>
<view class="item">Item 3view>
view>
.container {
position: relative;
}
.item {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: #f2f2f2;
padding: 10px;
}
<view class="container">
<view class="block">Block 1view>
<view class="block">Block 2view>
<view class="block">Block 3view>
view>
.container {
background-color: #f2f2f2;
padding: 10px;
}
.block {
background-color: white;
padding: 10px;
margin-bottom: 10px;
}
、 和 等 HTML 标签来创建表格布局。Table 布局适用于显示和排列多个数据项的情况。
<table class="table">
<tr>
<td>Item 1td>
<td>Item 2td>
<td>Item 3td>
tr>
<tr>
<td>Item 4td>
<td>Item 5td>
<td>Item 6td>
tr>
table>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
.table {
width: 100%;
border-collapse: collapse;
}
td {
border: 1px solid #ccc;
padding: 10px;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- Card 布局:Card 布局是一种常见的布局方式,通过使用卡片组件或自定义样式来创建卡片式布局。Card 布局适用于展示信息、图片和操作按钮等内容的场景。
<view class="card">
<image class="image" src="image.jpg">image>
<view class="content">
<text class="title">Card Titletext>
<text class="description">Card Descriptiontext>
<button class="button">Click Mebutton>
view>
view>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
.card {
display: flex;
background-color: white;
padding: 10px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.image {
width: 100px;
height: 100px;
object-fit: cover;
border-radius: 4px;
}
.content {
flex: 1;
margin-left: 10px;
}
.title {
font-size: 16px;
font-weight: bold;
}
.description {
margin-top: 8px;
color: #666;
}
.button {
margin-top: 10px;
background-color: #007aff;
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
这些是微信小程序开发中常用的布局方式。你可以根据具体的页面需求和设计来选择合适的布局方式。这些布局技术可以帮助你创建灵活、响应式和美观的小程序页面。
-
相关阅读:
vscode setting.json 全局设置 工作区设置 位置 优先级
C语言面试必看-指针笔试题详解
ZA7783是一颗将单路MIPI DSI信号转换成单路LVDS/TTL信号的转接芯片
ggcor替代包:linkET,相关图,mantel test可视化
【示波器专题】示波器带宽对测量的影响
蜂鸟E203学习笔记(四)——取指
微信小程序自定义方法submitPwd(e){}传入的e有什么作用
基于线性回归根据饮食习惯和身体状况估计肥胖水平
Javaweb之javascript的详细解析
C++并发与多线程学习笔记--线程启动、结束,创建线程多法
-
原文地址:https://blog.csdn.net/ultramand/article/details/136519319
-
最新文章
-
沪漂五周年了:我越来越迷茫了
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU