新聞中心
在HTML中,將元素放在頁(yè)面底部的方法有很多,這里我將介紹兩種常用的方法:使用CSS定位和使用Flexbox布局。

方法一:使用CSS定位
1、使用絕對(duì)定位(absolute positioning):
絕對(duì)定位是CSS中的一種定位機(jī)制,它允許你相對(duì)于最近的非靜態(tài)定位父元素(即position屬性不為static的元素)來(lái)定位一個(gè)元素,要將元素放在底部,你可以設(shè)置其top值為0,left值為0,然后使用bottom屬性將其固定在底部。
示例代碼:
I am at the bottom of the page!Some other content...
2、使用固定定位(fixed positioning):
固定定位與絕對(duì)定位類似,但它是相對(duì)于視口(viewport)而不是最近的非靜態(tài)定位父元素來(lái)定位元素的,要將元素放在底部,你可以設(shè)置其top值為0,left值為0,然后使用bottom屬性將其固定在底部,注意,固定定位的元素不會(huì)隨著頁(yè)面的滾動(dòng)而移動(dòng)。
示例代碼:
I am at the bottom of the page! (even when you scroll)Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
Some other content...
名稱欄目:html如何設(shè)置放在底部
網(wǎng)頁(yè)鏈接:http://m.fisionsoft.com.cn/article/cdgjdji.html


咨詢
建站咨詢
