skip to Main Content

everything seem to be working fine in the website’s home page , but all my div elements get this unwanted margin on the right.

I tried using the "width:100%" I used the max and min-width properties also, but nothing seems to be working.and its beginning to make me feel overwhelmed . I need all the help this poor beginner can get please .

2

Answers


    1. Reset CSS

    You might want to reset CSS as follows. I will show you my way that I love to use before setting up the project.

    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }
    

    This might remove all unwanted and unexpected redundant margin and paddings in your website.

    Also, check out by yourself with opening developer tool and mouse hover on the part where you think it looks awkward. Some html tags such as <h1> might have default margin/padding.

    1. You may want to try to use fit-content CSS property for this. This allows you to tell element to consumes as fit as possible along with the content in itself. This might also help to delete unwanted margin/padding.
    Login or Signup to reply.
  1. Maybe there is a parent container that has a fixed width or padding.
    Or maybe it is overflowing horizontally and causing a scrollbar to appear.
    In that case, add this to your divs:

    overflow-x: hidden;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search