首頁  >  問答  >  主體

固定頂部標題,不受其他內容幹擾的方法

這是我現在的程式碼

#h1{
    font-family: 'open-sans';
    position: absolute;
    color: white;
    font-size: 16px;
    left: 850px;
    margin-top: 5px;
    position: fixed;
}

沒有任何效果,我在痛苦中也嘗試過使用位置黏性,但它不起作用

P粉154228483P粉154228483403 天前466

全部回覆(1)我來回復

  • P粉738346380

    P粉7383463802023-09-13 10:39:01

    你應該移除 position: absolute; 只保留 position: fixed;

    h1{
    position: fixed;
    font-family: 'open-sans';
    color: white;
    font-size: 16px;
    background-color: black;
    top: 0;}

    希望這能幫到你。 你也可以使用 background-color 來使其顯示正確。

    回覆
    0
  • 取消回覆