1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Align menu nav with image logo

Discussion in 'CSS' started by piropeator, Dec 4, 2015.

  1. #1
    Hi. I have this code, is a simple example.
    <!DOCTYPE html>
    <html lang="en">
        <meta charset="UTF-8">
        <link rel="stylesheet" href="estilos.css">
            <div class="logo">
                <img src="logo_demo.jpg" alt="logo">
                    <li><a href="">Opción 1</a></li>
                    <li><a href="">Opción 2</a></li>
                    <li><a href="">Opción 3</a></li>
                    <li><a href="">Opción 4</a></li>
                    <li><a href="">Opción 5</a></li>
    body {
        background: #fffffa;
    header {
        width: 100%;
    header .logo {
        float: left;
    header nav {
        background: #024959;
        float: right;
    header nav ul {
        list-style: none;
    header nav ul li {
        float: left;
    header nav ul li a {
        color: #fff;
        padding: 20px;
        display: inline-block;
        text-decoration: none;
    Code (CSS):
    I want the height of the nav menu is the same as the logo image.
    The logo image logo image can be any size and que nav (menu) should have the same height.
    After that I want to get the menu in a responsive code.
    Some body can help me?
    piropeator, Dec 4, 2015 IP
  2. COBOLdinosaur

    COBOLdinosaur Active Member

    Likes Received:
    Best Answers:
    Trophy Points:
    So you are trying to be trendy with HTML5... ul (which is semantically a list) inside nav which is semantically a list of links is not trendyy; it is just stupid. as for controlling the height you could try setting height 100% and it should size to the container, bu then it will be sitting at the top of the wrapper. if you want the content and elements of the menu to spread out and fill the area you will probably need to script and end up with yet another crap page on the internet that needs javascript to do layout.

    You could try styling with display: table-cell so you have text vertical align to handle positioning, but I don't see how you resize a menu to a logo without some kind of ugly distortion to one or both elements.
    COBOLdinosaur, Dec 18, 2015 IP
  3. piropeator

    piropeator Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    But the menu has not changed at all, just the height of the entire nav.
    The menu height should not change because it is independent of the height of the nav.
    But I want to change the image of the logo on the other without changing much height nav.
    piropeator, Dec 21, 2015 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Ok, for starters a logo is typically NOT content, its a presentational affectation. As such it has ZERO business in the markup as a IMG tag. It is also HIGHLY unlikely you are doing anything that actually warrants that DIV around it. Of course you've also got the HTML 5 code-bloat redundancies in there so Christmas only knows how you'd have a proper document structure.

    IF you kept the IMG tag just set everything to inline-block and vertical-align:middle -- BUT...

    Really that div/img should be a H1 with text inside it and a image replacement method like gilder-levin. Float the H1, pad ONLY the top of the menu until it drops to where you want it, and be prepared to change that with media queries when the screen is too small to fit them side-by-side.

    That said without seeing the image in question it's kind-of hard to say what the proper code would be. Content dictates markup, content and markup dictate style and layout.
    deathshadow, Dec 21, 2015 IP