position: fixed; breaking my web page

BOT Irwin

Code:

<body>
    <div class="header">
        <div class="header-logo"><a href="#">Wanye Kest Designs</a></div>
            <nav class="header-nav">
                <a href="#">Work</a>
                <a href="#">Conatact</a>
            </nav>
    </div>
    <div class="pagess">Pages will go here</div>
</body>

/////////////////////////////////////// CSS:

body {
    background-color: #f3efed;
    font-family: "arial", sans-serif;
    color: #8e4e13;
    margin: 0;
}
.header-logo a {
    color: #8e4e13;
    text-decoration: none;
}
.header-logo {
    font-size: 24px;
    font-weight: bold;
    line-height: 28px;
}
.header {
    padding: 15px;
    overflow: auto;
}
.header-nav {
    float: right;
}
.header-logo {
    float: left;
}
.header-nav a { 
    color: #C3A286; 
    text-decoration: none; 
    margin-left: 5px;
    margin-right: 5px;
    line-height: 28px;
}

With this code, Nav links and header logo are one the same verticle alignment, opposite sides of page, and a text "Pages will be here" is positioned below the header logo perfectly.

My issue is that as soon as I enter position: fixed; below the .header selector, the Navigation links re-position themselves to overlap the header logo on the left side of the page, and the "Pages will be here" text re-positions itself above the header.

Please understand I'm extremely new to web design (HTML, CSS, JS, etc...) and the training program I refer to doesn't have a trouble-shooting section, videos or a forum (HACKSAW Academy).

Can someone Identify the problem? I'm typing the code exactly as it tells me and can't find a workaround.

without position: fixed;

With position: fixed;

timolawl

Position: fixed; takes the element out of the normal flow of the document, so that is where the overlap is coming from. By default, this moves all the elements to the top left. Also, float is superseded by position: fixed, as float is in the flow of the document while again position: fixed is not. The only remaining element not position: fixed is your pagess class, which rightly takes up the top-left spot in the flow of the document.

Here's something you can work with:

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

body {
    background-color: #f3efed;
    font-family: "arial", sans-serif;
    color: #8e4e13;
    margin: 0;
}
.header-logo a {
    color: #8e4e13;
    text-decoration: none;
}
.header-logo {
    font-size: 24px;
    font-weight: bold;
    line-height: 28px;
}
.header {
    padding: 15px;
    overflow: auto;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
}
.header-nav {
    background: green;
    display: inline-block;
    vertical-align: bottom;
    margin-left: calc(55% - 100px);
}
.header-logo {
    background: red;
    display: inline-block;
    vertical-align: bottom;
}
.header-nav a { 
    color: #C3A286; 
    text-decoration: none; 
    margin-left: 5px;
    margin-right: 5px;
    line-height: 28px;
}

.pagess {
    margin-top: 48px;
    margin-left: 24px;
}
<body>
    <div class="header">
        <div class="header-logo"><a href="#">Wanye Kest Designs</a></div>
        <nav class="header-nav">
          <a href="#">Work</a>
          <a href="#">Conatact</a>
        </nav>
    </div>
    <div class="pagess">Pages will go here</div>
</body>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why is my nav bar with 'position:fixed' displaying at bottom of web page not bottom of viewport on mobile?

From Dev

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

From Dev

position: fixed overlapping page

From Dev

How can I make codes in my web page word wrap into a fixed page-width

From Dev

Css position on web page

From Dev

How to scroll div with page without position: fixed?

From Dev

Get all elements with `position:fixed` in an HTML page?

From Dev

JQuery Position:Fixed 'NAVBAR' by scrolling the page

From Dev

JQuery Position:Fixed 'NAVBAR' by scrolling the page

From Dev

jQuery Mobile Dialog Page - Fixed Position Header

From Dev

Position fixed element within fixed element relative to page

From Dev

Position: Fixed - pushing my footer over header

From Dev

Position fixed acting like position relative ( scrolling with page )

From Dev

Why my nav-bar hides my texts in a fixed position?

From Dev

Making the web page fixed and un-zoomable

From Dev

Fixed div top of web page broken result

From Dev

How to determine Breaking point of my Web application using JMeter?

From Dev

Set multiple div elements to "position: fixed" at the bottom of a page

From Dev

Prevent page scrolling to top upon adding fixed position

From Dev

Parts of page are invisible when scrolling on Safari 7 with position:fixed elements

From Dev

Position fixed element in bottom right corner of page with CSS3

From Dev

Header Div position fixed on top of page but on load show a div on top of it

From Dev

Fixed position div causes page to be truncated in less common mobile browsers

From Dev

how to set up a fixed position image in a one page layout

From Dev

How to fix the position of a picture on a fixed page, in MS Word 2013?

From Dev

Need a CSS solution to stay top left with page scrolling (not position:fixed)

From Dev

Why isn't my margin working with position: fixed?

From Dev

Why does setting position of my div to fixed interfere with flyout div?

From Dev

position fixed to absolute on scroll make my img jump

Related Related

  1. 1

    Why is my nav bar with 'position:fixed' displaying at bottom of web page not bottom of viewport on mobile?

  2. 2

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

  3. 3

    position: fixed overlapping page

  4. 4

    How can I make codes in my web page word wrap into a fixed page-width

  5. 5

    Css position on web page

  6. 6

    How to scroll div with page without position: fixed?

  7. 7

    Get all elements with `position:fixed` in an HTML page?

  8. 8

    JQuery Position:Fixed 'NAVBAR' by scrolling the page

  9. 9

    JQuery Position:Fixed 'NAVBAR' by scrolling the page

  10. 10

    jQuery Mobile Dialog Page - Fixed Position Header

  11. 11

    Position fixed element within fixed element relative to page

  12. 12

    Position: Fixed - pushing my footer over header

  13. 13

    Position fixed acting like position relative ( scrolling with page )

  14. 14

    Why my nav-bar hides my texts in a fixed position?

  15. 15

    Making the web page fixed and un-zoomable

  16. 16

    Fixed div top of web page broken result

  17. 17

    How to determine Breaking point of my Web application using JMeter?

  18. 18

    Set multiple div elements to "position: fixed" at the bottom of a page

  19. 19

    Prevent page scrolling to top upon adding fixed position

  20. 20

    Parts of page are invisible when scrolling on Safari 7 with position:fixed elements

  21. 21

    Position fixed element in bottom right corner of page with CSS3

  22. 22

    Header Div position fixed on top of page but on load show a div on top of it

  23. 23

    Fixed position div causes page to be truncated in less common mobile browsers

  24. 24

    how to set up a fixed position image in a one page layout

  25. 25

    How to fix the position of a picture on a fixed page, in MS Word 2013?

  26. 26

    Need a CSS solution to stay top left with page scrolling (not position:fixed)

  27. 27

    Why isn't my margin working with position: fixed?

  28. 28

    Why does setting position of my div to fixed interfere with flyout div?

  29. 29

    position fixed to absolute on scroll make my img jump

HotTag

Archive