1. 使用view布局。小程序
1.1 代码以下:bash
<!-- wxml-->
<view class="container">
<view class="content">
// 具体 wxml内容
<view class="neirong"></view>
<view class="neirong1"></view>
</view>
</view>
复制代码
<!-- wxss-->
.container {
overflow-y: scroll; *容许y轴滚动展现*/
overflow-x: hidden;
width: 105vw; /*超过屏幕宽度*/
position: absolute;
}
.content{
width: 100vw;
position: absolute;
left: 0;
top:0;
}
.neirong{
height: 900px;
width: 100%;
background-color: rgb(0, 255, 191);/*绿色*/
}
.neirong1{
height: 900px;
width: 100%;
background-color: rgb(255, 0, 34) /*红色*/
}
复制代码
1.2 效果图:xss
2. 使用 <view-scroll>布局
2.1 代码以下:ui
<!-- wxml -->
<scroll-view
// 第一层(宽度设超过100vw)
class="scroll-view"
scroll-y="{{true}}">
// 第二层
<view class="box">
<view class="content1">
<text class="text">23456789101112wweweweqwewq</text>
</view>
<view class="content2"></view>
</view>
</scroll-view>
复制代码
<!-- wxss -->
/* 最外层的 scroll-view*/
.scroll-view{
width: 105vw;
position: absolute;
overflow-x:hidden;
height: 100vh;
}
/* 第二层view*/
.box{
width: 100vw;
position: absolute;
top: 0;
left: 0;
}
/* 内容区域 */
.content1 {
height: 900px;
font-size: 60px;
background: rgb(153, 121, 51);
width: 100%;
}
.content2{
height: 900px;
width: 100%;
background: rgba(51, 153, 85, 0.705);
}
.text{
width: 100%;
/* 加上下边三个属性,text和view才会自动换行 */
word-wrap: break-word;
word-break: break-all;
white-space: pre-line;
}复制代码
2.3 效果图:
spa