WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add Styling for New Div (4 posts)

  1. Photog
    Member
    Posted 2 years ago #

    I've created a new <div> in my header.php called AdAboveHeader and added some text to it for layout purposes. I now want to incorporate it into the style.css file so that I can incorporate some additional styling of this new div. I'm having trouble getting the coding right.

    I've tried simply adding a new section in the CSS above the h1 as follows:

    AdAboveHeader {
    background-color: #393939;
    }

    but that didn't work. Assistance appreciated.

    Thanks.

  2. VeVas
    Member
    Posted 2 years ago #

    Did you use class or id to name the div?
    if its like this:
    <div id="AdAboveHeader"> the css-code should be:

    #AdAboveHeader {
    background-color: #393939;
    }

    if its like this:
    <div class="AdAboveHeader"> the css-code should be:

    .AdAboveHeader {
    background-color: #393939;
    }
  3. Photog
    Member
    Posted 2 years ago #

    I used class. Missed putting the '.' in the CSS.

    Without anything in the CSS, the new div appears as it should. But when I put anything in the CSS, the new div disappears and the formatting gets applied where it shouldn't.

    Since this new div is going above the header, I put the CSS directly above the /*Headings*/ section of the CSS. The new div disappeared and the styling got applied to a sidebar. If I put the new styling under the /*Headings*/ section and directly above the h1 (main header), the new div disappears and styling gets applied nowhere (that I can see).

    EDIT: I determined the problem, but not how to fix it. I want to fix this new div in position at the top of the page so it doesn't scroll. With position: fixed; the div disappears. If I remove the fixed positioning so that the div scrolls, it's fine.

    Thanks.

  4. Photog
    Member
    Posted 2 years ago #

    Resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.