如何让主内容 div 填充屏幕高度(CSS 和 HTML)


position 属性指定对元素使用的定位方法类型(static、relative、absolute、fixed 或 sticky)。

在下面给出的示例中,未以百分比指定高度,也不需要 jQuery

.mainbody{  
   position: absolute;//here we are setting the position of an element as absolute
   top: 30px; /* here we are defining Header Height to 30 px */
   bottom: 10px; /*here we are defining  Footer Height to 10 px */
   width: 100%;// here we are setting the width to 100%
}

更新于: 2020-03-04

363 次浏览

开启你的 职业生涯

完成课程获得认证

开始
广告
© . All rights reserved.