老师,帮忙解答一下
来源:2-7 搜索结果页
Syrena3447375
2020-03-29 20:19:29
老师,什么时候写width:100%;height:100%;什么时候写position:absolute;top,bottom,left.right=0;??这两种样式不是都是让这个标签占满全屏吗??
为什么我的.search-wrapper和.search-container样式写position的时候滚动条可以用,写成width就不能用了
这样滚动条不能用:
.search-wrapper {
overflow: hidden;
width: 100%;
height: 100%;
background-color: $bgc-theme;
}
.search-container {
overflow: hidden;
width: 100%;
height: 100%;
background-color: $bgc-theme;
}
这样滚动条可以用
<template>
<transition name="search">
<div class="search-container">
<div class="search-wrapper">
<div class="g-header-container">
<search-header></search-header>
</div>
<div class="g-content-container">
<search-scroll>
<search-hot></search-hot>
<search-history ref="history" @show-confirm="showConfirm"></search-history>
</search-scroll>
</div>
</div>
<me-confirm ref="confirm" :visible='visible' @confirm='confirm' @cancel='hideConfirm'></me-confirm>
</div>
</transition>
</template>
<script>
import SearchHeader from './header.vue'
import SearchScroll from 'base/scroll'
import SearchHot from './hot'
import SearchHistory from './history'
import MeConfirm from 'base/confirm'
import {SEARCH_HISTORY_KEYWORD_KEY} from './config'
import storage from 'assets/js/storage'
export default {
name: "Search",
components: {
SearchHeader,
SearchScroll,
SearchHot,
SearchHistory,
MeConfirm
},
data() {
return {
visible: false
}
},
methods: {
showConfirm() {
this.$refs.confirm.show()
},
hideConfirm() {
this.$refs.confirm.hide()
},
confirm() {
this.$refs.confirm.hide()
this.$refs.history.clearAll()
}
},
}
</script>
<style lang="scss" scope>
@import "~assets/scss/mixins";
.search-wrapper {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: $search-z-index;
background-color: $bgc-theme;
}
.search-container {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: $search-z-index;
background-color: $bgc-theme;
}
.search-enter-active, .search-leave-active {
transition: all .3s;
}
.search-enter, .search-leave-to {
transform: translate(100%, 0);
}
</style>
2回答
好帮手慕糖
2020-03-30
同学你好,设置层级的时候,需要使用left、right、top等设置位置的时候,都需要使用定位。
祝学习愉快~
好帮手慕糖
2020-03-30
同学你好,关于你的问题,回答如下:
1、这里两个都可以设置全屏。看是否需要使用定位即可,若是要使用定位就用后面的一种方法。
2、因为这里要使用定位,所以需要使用后面一种方法哦。
祝学习愉快~
相似问题