samedi 25 avril 2015

how to change margin when the image width changes?


i have a fixed header and when i resize the browser window the logo on the header resizes and now i want to change the margin of the logo when the image is resized how do i do that?

this is the jquery that i use to resize the image

$(window).on('load resize', function() {

    var maxsize = 2560;
    var screenwidth = $(this).width();
    var factor = 0.27*screenwidth-(maxsize-screenwidth)*0.05;
    if (factor > 2560) factor = 2560;

    $('#logo').css('width', factor)
  });
});
CSS:
#logo{
        margin-top:5px;
        margin-left:10px;
        float:left;
        cursor: pointer;
        display:block;
        min-width:220px;
        height: auto;
        width: auto\9; /* ie8 */
}

Aucun commentaire:

Enregistrer un commentaire