使用伪类实现高度自适应

具体实现代码如下

html {
   min-height: 100%;
   position: relative;
}
.sidebar {
   float: left;
   position: static;
   padding-left: 0;
   padding-right: 0;
}
.sidebar:before {
   content: "";
   display: block;
   width: inherit;
   position: absolute;
   top: 0;
   bottom: 0;
   z-index: -1;
   background-color: inherit;
   border-style: inherit;
   border-color: inherit;
   border-width: inherit;
}

即可在页面不断变化时,左侧的sidebar高度自适应浏览器高度

posted @ 2016-11-07 17:09  默默到来  阅读(644)  评论(0编辑  收藏  举报