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