为了项目需求,让背景图片不滑动,内容部分滑动。所以html,body设为width:100%;height:100%;根节点设置为width:100%;height:745px;background:url("../...png") no-repeat;
由于body为一屏大小,所以不可滑动,此时要给根节点加个滑动组件包裹所有的可滑动部分。但由于使用滑动组件,导致原来里面一个能左右滑动的div不能滑动了,应该是冲突了。此时应该使用flex
html部分
<div class="historyList" v-if="historyStationList.length" >
<VScroll class="historyScroll"
:scrollingX=true
:scrollingY=false
>
<div class="stationArea">
<div
class="stationLabel"
v-for="(item, index) in historyStationList"
:key="index"
@click="clickHistoryStaion(index)"
>
<p>{{item["depCity"].deptCityName}}-{{item["arrCity"].arrCityName}} </p>
</div>
</div>
</VScroll>
<div class="clearHistoryList" @click="clearHistoryStation">
清除历史
</div>
</div>
css部分:
.historyList{
.flexbox;
.flex-direction(row);
font-size: 24*@rmw2;
margin:12*@rmw2 -10*@rmw2 -10*@rmw2 -10*@rmw2;
width: 100%;
.historyScroll{
width: 80%;
.flexbox;
.stationArea{
.flexbox;
.flex-direction(row);
.align-items(center);
height:40*@rmw2;
padding:6*@rmw2 4*@rmw2;
box-sizing: border-box;
.stationLabel{
color: #999;
margin-right: 29*@rmw2;
text-align: center;
display: inline-block;
p {
white-space: nowrap;
}
}
}
}
.clearHistoryList{
margin-left: 20*@rmw2;
width: 20%;
display: inline-block;
color: #4b93ff;
font-size: 24*@rmw2;
margin-right: -0.32rem;
height: 40*@rmw2;
line-height: 40*@rmw2;
margin-top: 0*@rmw2;
text-align: right;
}
}
网友评论