Forums

Centering in menu (7 posts)


  1. Moderator
    Posted 7 years ago #

    Hi,
    Just a quick question. Can anyone tell me how to center an image in my menu area 1. in the li and 2. outside of the li area ?
    I know it's probably something very simple - I just can't work it out. I don't want to center all images - only selected images here and there.
    Thanks to anyone who can provide some assistance.

  2. Mark (podz)
    Support Maven
    Posted 7 years ago #

    Not sure if it will break validation, but in your css, create a class to center.
    div.cent {
    text-align: center;
    }
    Then edit index.php, and in the menu list, do this:
    <div class="cent">
    <img src="whereeveryourimageis.jpg" alt="" />
    </div>

    That's one way ......

  3. Mark (podz)
    Support Maven
    Posted 7 years ago #

    Firefox is playing by the rules, as usual, IE is not :)
    As it's a link, use the link manager for this
    Using the image as a link will place it inside the box that your group it into.
    Add the link, enable images and addthe uri for the image. That should do the trick, but it will be indented to the same level as the other elements.
    Or....... in index.php, just before the image, insert a closing /ul tag, then straight after, an opening ul tag.
    Not sure what the validator will think though... :)
    (not that it's sentient of course!)


  4. Moderator
    Posted 7 years ago #

    Thanks again Podz.
    Re: the link manager option
    Sounds good except I am hoping to put a few images in places other than the link sections.
    Re: /ul and ul option
    Gave it a try but it sent the image way over to the left and not a good result.
    I am a bit surprised - I thought such a simple task as putting an image in a menu would be an easy task.
    Life's good when you learn something every day.
    Thanks for trying Podz :)

  5. Anonymous
    Unregistered
    Posted 7 years ago #

    Shadow I have looked at your CSS At the moment the img is in a div class="cent". I could not see the corresponding selector in the css at all.
    There should be something like:
    .cent {
    margin-left: auto;
    margin-right: auto;
    }
    I might have overlooked it.

  6. Mark (podz)
    Support Maven
    Posted 7 years ago #

    This is what I just sorted for my daughter.
    Page still validates, but I'm sure it can be done better !
    In the css, add this:
    #menu .icon {
    background-image: url("image.jpg");
    background-repeat: no-repeat;
    margin-left: 110px; // adjust as needed
    padding: 25px 25px 45px 25px; // adjust as needed
    }
    In index.php, add this:

    • <div class="icon"></div>

  7. Put this where you want your images to appear.
    If you want the same image between all your menu items, this alone will do.
    If you want say 4 images in your index, then create #menu .icon1, #menu .icon2 etc per style sheet and place accordingly. Test the margin and padding for each image each time.
    This does not separate link categories - it only goes between those items that you can see in the menu div in index.php
    Any improvements on this very welcome !

  • Anonymous
    Unregistered
    Posted 7 years ago #

    Anonymous: You probably looked in my wp-layout.css which is not my current css.
    Podz: Thanks, will give it a try. I think the problem rests with my padding and margins so I will play around with it and see what happens. For now - it looks fine in IE but Firefox needs a few more specifications. Wouldn't it be nice if they all worked the same :)

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.