• Hi! I’m working on a little menu, here is it:

    MENU

    the are two problems:

    1) Div1, Div2, Div3, Div4, Div5 are not inside div “menu”
    2) for the mobile version i’m not able to set a padding for the divs

Viewing 1 replies (of 1 total)
  • Your menu structure should be made up of a unordered list, like so:

    <div class="menu">
        <ul>
            <li class="Div1"><a href="#chi-siamo">Chi Siamo</a></li>
            <li class="Div2"><a href="#contatti">Dove Trovarci</a></li>
            <li class="Div3"><a href="#servizi">Servizi Investigativi</a></li>
            <li class="Div4"><a href="#formazione">Formazione</a></li>
            <li class="Div5"><a href="#news">News</a></li>
        </ul>
    </div>

    Which you can simply style with:

    .menu {
        width:100%;
        text-align: center;
        box-shadow: 0px 0px 6px 2px #D8D9DA;
    }
    
    .menu ul {
        border: 1px solid #000;
    }
    
    .menu li { 
        display: inline-block; 
        padding: 10px 15px;
    }

    You can control responsive styles like this:

    @media screen and (max-width: 620px) {
        .menu li { 
            padding: 25px; 
        }  
    }

    I have removed the padding and border away from the menu class as you want this to be 100% wide, the border has been applied to the ul with the padding now being applied to each li instead.

    JSFiddle

    Hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘Align div inside parent div & padding not working’ is closed to new replies.