SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    I want my 4th arrow! garlinto's Avatar
    Join Date
    Jun 2002
    Location
    Riding the electron wave
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Center a DIV within a DIV

    Probably a dumb question:
    I have a <DIV> menu that I have nested inside of a parent <DIV>. I know how to center the text inside the <DIV>, but how do I center the entire nested <DIV> block within the parent tags?
    Also, I want each of the menu <div>'s to have a hover color. I know that you can give the text a background-color, but I want each <div> in the menu to have a hover color for the links.

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For IE compatibility, set "text-align: center;" for the containing DIV.

    For NS/Opera compatibility, set "margin-left: auto; margin-right: auto;" for the child DIV.

    Both of these assume you have a specified width for the child DIV.

    To create changing colors, you could use the :hover pseudo-tag, but DIV:hover will only work with Mozilla-based browsers at present.

    A better way, as well as one that supports IE and NS, would be to stop using a seperate DIV for each link, and rather set the display style of the A tag to block... (give it a class...)

    ie: A.menu { display: block; }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •