目录

css不出现滚动条

目录

css不出现滚动条

这是现在的样式,左边有滚动条,右边没有

https://i-blog.csdnimg.cn/direct/296c9c315d2942f8ba3e7cf3c0753112.png

/* styles.css */
.guRpLZ {
  display: flex;
  flex-direction: column;
}
.dMItjA {
  height: 63px;
  border-bottom: 1px solid var(--TY-Line-1);
  background-color: rgb(251, 251, 253);
}
.gIoENS {
  flex: 1 0 0%;
  display: flex;
  background-color: #f7f8fc;
  overflow: hidden;
}
.bXUKwe {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
}
.kShHHP {
  min-width: 560px;
  height: 100%;
  flex: 1 1 0%;
  position: relative;
  background-color: #f7f8fc;
}
.docContent {
  width: 100%;
  height: calc(100vh - 64px);
  background-color: #f7f8fc;
}

这是代码,大概都是flex布局加上overflow:srcoll或者hidden,但是右边没有滚动条 ,排查后发现下面这个样式设置了flex布局但是没有高度导致的

https://i-blog.csdnimg.cn/direct/49a40408498c4382831f67bd57a603e3.png

修改后加上height就出现滚动条了

https://i-blog.csdnimg.cn/direct/121ead67871c4bdaa5b95f82d96e19cd.png

https://i-blog.csdnimg.cn/direct/75311f4bace94f479dd47dad93efd2d2.png

总结:如果在flex布局中,希望出现滚动条,保证父元素以及祖先元素要有高度 ,要么有具体的px或者100%