首页  >  问答  >  正文

固定顶部标题,不受其他内容干扰的方法

这是我现在的代码

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

没有任何效果,我在痛苦中也尝试过使用位置粘性,但它不起作用

P粉154228483P粉154228483403 天前470

全部回复(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
  • 取消回复