Home > Back-end >  How do I make my title stick to the top, while the other contents go under the title and doesn'
How do I make my title stick to the top, while the other contents go under the title and doesn'

Time:11-30

this is my code right now

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

nothing works im in agony also tried using position sticky but it didnt work

CodePudding user response:

You should remove position: absolute; and only position: fixed; should remain.

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

Hope that helps. And you can also use background-color to make it look right.

CodePudding user response:

bro just use one position property, you are using two in the styles. Just apply three properties like:

.element {
    position: fixed; 
    top: 0; 
    left: 0;
    width 100%
}

CodePudding user response:

you can use position:sticky or position: fixed instead of position: absolute https://www.w3schools.com/howto/howto_css_sticky_element.asp

  • Related