skip to Main Content

Today I have encounterd a problem in css. I created a div named as main and its childrens is nav and box, in the box i have putted some content. when I fixed nav applying its poistion in css as fixed and also scrolling is going good but in the top and the bottom of the main box a spacing or gap is appearing I don’t know the reason why this happening. I’m beginner please help me.

I was expecting that the bottom and top gap not be there but after many tries it didn’t fixed. Please help me to get out of the problem. I’m beginner.

2

Answers


  1. can you share your code? It would help a lot.

    But basically you edit children like this.

    #parent:first-child {
    margin-top: 0px;
    

    }.

    This code is just example.

    Login or Signup to reply.
  2. It’s bit difficult to give the exact solution as you haven’t posted the code.
    I suggest the following.

    nav{
     position: fixed;
     top:0;
      left: 0;
     }
     /*use relative positioning for every element after nav with top: 0 and change to required px after seeing the result*/
    /*Also the make margin-top,margin-bottom and padding 0*/
    
    .box{
     position: relative;
     top: 0;
     margin: 0 auto;
     padding:0;
     }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search