如何讓主內容 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 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始
廣告