<template>
<!-- 上下固定,中间滚动布局;兼容ios和安卓以及pc -->
<div class="container">
<div class="header-exp">聊天头部</div>
<div class="topcontent">
<div class="talk-sticky">
<div class="topcontent-text">登录享保障,遇虚假欺诈,百度助你维权</div>
<div class="topcontent-fixd">
这个一个相对topcontent固定定位的设计方案
</div>
</div>
</div>
<div class="chatview">
<div class="list" v-for="(item, index) in 20" :key="index">
{{ index + 1 }}
</div>
</div>
<!-- 注释下面就只有顶部固定 -->
<div class="footer">
<div class="footer-input">
<input type="text" />
</div>
<div class="footer-send">发送</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
.header-exp {
display: flex;
height: 50px;
background: blue;
}
.topcontent {
background-color: #fff;
width: 100%;
order: 2;
position: relative;
&-text {
padding: 15px;
background: #ccc;
}
&-fixd {
position: fixed;
/* top: ;这个top不能设置才能有效 */
left: 0;
right: 0;
z-index: 777;
background: #fff;
padding: 15px;
}
}
.chatview {
background-color: #f5f5f5;
flex: 1;
flex-direction: column;
justify-content: flex-start;
order: 4;
overflow-x: hidden;
overflow-y: scroll;
overscroll-behavior: none;
position: relative;
scroll-behavior: smooth;
.list {
padding: 15px;
}
}
.footer {
order: 6;
position: relative;
z-index: 1000;
padding: 10px 15px;
display: flex;
justify-content: space-between;
align-items: center;
&-input {
flex: 1;
overflow: hidden;
input {
width: 300px;
}
}
&-send {
}
}
}
</style>