WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Add Styling for New Div

[Resolved] Add Styling for New Div

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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;
    }

    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.

    Resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Add Styling for New Div’ is closed to new replies.