fixed问题

html:

<div class="wrap">
    <label for="sliderbartroggle" class="troggle">☰</label>
    <div class="content"></div>
    <div class="slidebar"></div>  
</div>

sass:

.content
  position: absolute
  width: 100vw
  height: 100vh
  top: 0
  background-color: wheat
  z-index: 0

.slidebar
  position: fixed
  left: 0
  top: 0
  width: 120px
  height: 1000px
  padding: 30px
  font-size: 16px
  color: black
  z-index: 0

为什么能实现

clipboard.png
米色div为什么不是从left为0开始的?

阅读 2.2k
1 个回答
.content
  position: absolute
  width: 100vw
  height: 100vh
  top: 0
  left: 0 // <----
  background-color: wheat
  z-index: 0
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题