Pedro Caseiro
Pedro Caseiro

Reputation: 161

Button with bigger size than expected

I'm currently doing a responsive website and I came across a bug which I think is simple to fix but can't really fix it. In my website there is a menu, which is vertical and pushed to the left. When i load the website the menu is hidden (to the left of the page obviously) and there is just a button showing, which is an image. When i click the button, the menu slides to the website. It is doing it's purpose but the problem is that the image (button) is not working like a button, because there is an invisible "bar" to the left of the button which goes all the way to the right side of the page, and if I click on that bar, it works as the button, it opens the menu.

HTML:

<div class="menu">

    <!--Ícone do menu-->
    <div class="icon-close">
        <img src="http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/close.png">
    </div>

    <!-- itens do menu -->
    <ul>
        <li><a class="tooltip" href="http://jeknowledge.pt/">Sobre nós</a></li>
        <li><a href="http://jeknowledge.pt/servicos/">Serviços</a></li>
        <li><a href="http://jeknowledge.pt/recrutamento/">Recrutamento</a></li>
        <li><a href="http://jeknowledge.pt/parceiros/">Parceiros</a></li>
        <li><a href="http://jeknowledge.pt/academy/">Academy</a></li>
        <li><a href="http://jeknowledge.pt/blog/">Blog</a></li>
        <li><a href="http://jeknowledge.pt/contactos/">Contactos</a></li>
        <li><a href="https://www.facebook.com/jeknowledge?fref=ts">Facebook</a></li>


    </ul>
</div>

<!-- Main body -->
<div class="estilo">

    <div class="icon-menu">
        <i class="fa fa-bars"></i>
        <img class="logo" alt="" src="C:\Users\Pedro\Desktop\projeto jeKnowledge\logo_sobre.png">
    </div>

CSS:

.menu {
    background: #202024 url('http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/black-thread.png') repeat left top;
    left: -285px;
    height: 100%;
    position: fixed;
    width: 285px;
}

/* estilos */



.menu ul {
    border-top: 1px solid #636366;
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu li {
    border-bottom: 1px solid #636366;
    font-family: 'Open Sans', sans-serif;
    line-height: 45px;
    padding-bottom: 3px;
    padding-left: 20px;
    padding-top: 3px;
}

.menu a {
    color: #fff;
    font-size: 15px;
    text-decoration: none;
    text-transform: uppercase;
}

.icon-close {
    cursor: pointer;
    padding-left: 10px;
    padding-top: 10px;
}

.icon-menu {
    color: #fff;
    cursor: pointer;
    font-family: 'Open Sans', sans-serif;
    font-size: 16px;
    padding-bottom: 25px;
    padding-left: 50px;
    padding-top: 25px;
    text-decoration: none;
    text-transform: uppercase;
}

.icon-menu i {
    margin-right: 5px;
}

.logo{
    width: 100px;
    height:100px;
    /* I THINK THE PROBLEM IS HERE!!!!!! */
}

// BOTÃO DO MENU!

$('.icon-menu').click(function(){
        $('.menu').animate(
            {left: '0px'},
            200);

        $('body').animate(
        {left: '285px'},
        200);
    });

    $('.icon-close').click(function(){
        $('.menu').animate({left: '-285px'},
        200);
        $('body').animate({left: '0px'},
        200);
    });

Upvotes: 0

Views: 1219

Answers (1)

Alex Wright
Alex Wright

Reputation: 456

If I'm understanding your problem correctly, it's because .icon-menu is a div, with display: block as the default display setting.

Setting this to display: inline-block should fix your issue.

.icon-menu {
    display: inline-block;
    /* other styles */
}

jsfiddle: http://jsfiddle.net/v1oj42j6/

Upvotes: 1

Related Questions