fixed position header overlapping

Gadawg099

Okay so I kind of have two problems. One is whenever I try to do position:fixed; on the .header it adds space to the bottom of the header and it makes the .main-content go behind the header and also adds margin to the top of the header. The other problem is whenever I did not have the fixed position there was space between the header and the main content and for some reason it the space is not there if I put a border on the main content. I've looked and looked over my code trying to find whats wrong with it and I just can't seem to find anything. Thanks for any help!

/***********************************
          LOGO
***********************************/
.header{
background-color: skyblue;
margin:0;
padding:0;
width: 100%;
}
.logo{
text-align: left;
display: block;
margin:0 15px 0px 15px;
}
#logo-large{
display: inline;
font-size: 3em;
font-weight: 200%;
font-family: 'Dosis' , sans-serif;
}
#logo-small{
display: inline;
font-weight:0;
font-size: 2.5em;
font-family: 'Dosis' ,sans-serif;
}
/************************************
           NAVIGATION
************************************/
nav ul{
list-style-type:none;
/****display: block;
padding: 5px;
margin: 5px;
text-align: center;****/
}
nav{
display:inline;
float: right;
}
nav ul li{
display: inline-block;
padding: 5px 0px;
margin: 0;
}
nav ul li a{
text-decoration: none;
padding:20px 12px 12px 12px;
color:black;
font-family: 'Muli', sans-serif;
font-size: 1.25em;
}
nav ul li a:active, nav ul li a:hover{
background-color: deepskyblue;
color: white;
}
/*************************************
           main content
*************************************/
.main-content{
background-color: grey;
font-family: 'Muli', sans-serif;
margin:0;
padding:10px;
border: 1px solid black;
}
body{
margin:0;
padding:0;
}
<!DOCTYPE html>
<html>
<head>
<title>FatHead | Blog</title>
<link href='http://fonts.googleapis.com/css?family=Dosis:400,500,600,700,800|Muli:400,300italic,400italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div class="header">
     <div class="logo">
        <h1 id="logo-large">FAT</h1> <h1 id="logo-small">HEAD</h1>
        <nav>
        <ul>
            <li><a href="index.html">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact</a></li>
            <li><a href="#">Categories</a></li>
        </ul>
        </nav>
    </div>
</div>
<div class="main-content">
    <h1>Welcome to my blog!</h1>
    <p>This would be where all the content inside the blog post goes.</p>
</div>
</body>    
</html>

Rohit Azad Malik

Now just add to this css define your .header position :fixed and define your body padding-top:65px;

 .header{
        position: fixed;
        left:0;
        right:0;
        top:0;
    }
    html body {
     padding-top: 65px;
    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Header in fixed position is overlapping with container div when the window is reduced in width

From Dev

Overlapping dynamic fixed header

From Dev

position: fixed overlapping page

From Dev

Position fixed overlapping issue?

From Dev

position relative overlapping position fixed

From Dev

position fixed element is overlapping into footer

From Dev

Fixed position not working for header

From Dev

position:fixed navigation header overlapping browser scroll bar when using overflow-x

From Dev

Keeping fixed footer and header from overlapping

From Dev

Prevent images from overlapping a fixed header

From Dev

DIV Position Fixed, inner content overlapping

From Dev

Header is disappearing when the position is fixed

From Dev

Scroll to anchor position with fixed header

From Dev

"position:fixed" Not Working For Header Menu

From Dev

CSS position:fixed is working for the header but not for the footer

From Dev

Fixed header position in bootstrap 3 modal

From Dev

CSS Position fixed not fixing header to top

From Dev

Css position fixed on header hides content

From Dev

Sticky header slide into fixed position from top

From Dev

jQuery Mobile Dialog Page - Fixed Position Header

From Dev

Adjust position of DIV beneath fixed header PHP

From Dev

Position: Fixed - pushing my footer over header

From Dev

Anchors not working when header's position is fixed

From Dev

Header fixed by css position:fixed and lightbox effect get overlayed by it

From Dev

Fixed header wont keep fixed after window is reloaded in same position

From Dev

Why section of web page overlaps the header even if the position of header is fixed

From Dev

disappearing position fixed header in ios7 mobile safari

From Dev

Stop header footer from loosing position:fixed with click - Jquery Mobile

From Dev

When navigating to #id, element is hidden under fixed position header

Related Related

  1. 1

    Header in fixed position is overlapping with container div when the window is reduced in width

  2. 2

    Overlapping dynamic fixed header

  3. 3

    position: fixed overlapping page

  4. 4

    Position fixed overlapping issue?

  5. 5

    position relative overlapping position fixed

  6. 6

    position fixed element is overlapping into footer

  7. 7

    Fixed position not working for header

  8. 8

    position:fixed navigation header overlapping browser scroll bar when using overflow-x

  9. 9

    Keeping fixed footer and header from overlapping

  10. 10

    Prevent images from overlapping a fixed header

  11. 11

    DIV Position Fixed, inner content overlapping

  12. 12

    Header is disappearing when the position is fixed

  13. 13

    Scroll to anchor position with fixed header

  14. 14

    "position:fixed" Not Working For Header Menu

  15. 15

    CSS position:fixed is working for the header but not for the footer

  16. 16

    Fixed header position in bootstrap 3 modal

  17. 17

    CSS Position fixed not fixing header to top

  18. 18

    Css position fixed on header hides content

  19. 19

    Sticky header slide into fixed position from top

  20. 20

    jQuery Mobile Dialog Page - Fixed Position Header

  21. 21

    Adjust position of DIV beneath fixed header PHP

  22. 22

    Position: Fixed - pushing my footer over header

  23. 23

    Anchors not working when header's position is fixed

  24. 24

    Header fixed by css position:fixed and lightbox effect get overlayed by it

  25. 25

    Fixed header wont keep fixed after window is reloaded in same position

  26. 26

    Why section of web page overlaps the header even if the position of header is fixed

  27. 27

    disappearing position fixed header in ios7 mobile safari

  28. 28

    Stop header footer from loosing position:fixed with click - Jquery Mobile

  29. 29

    When navigating to #id, element is hidden under fixed position header

HotTag

Archive