A
A
Alexey Lebedev2011-11-03 00:32:49
css
Alexey Lebedev, 2011-11-03 00:32:49

Justify Menu Width + JS

The menu is dynamic and changes via JS.
If pasting the code is simple in HTML, the whole menu ok is justified in width. If through JS, then I can't justify it in any way. It shifts to the left.
Can something like this be done?

.menu
{
    margin: 0px 30px;
    top: 9px;
    position: relative;
    text-align: justify;
    text-align-last: justify;
    min-width: 400px;
}
.img_menu
{
    position: absolute;
    border: 1px solid #1BB38D;
    width: 28px;
    height: 28px;
}

.title_menu
{
    top: 7px;
    left: 35px;
    display: inline-block;
}
.menu div
{
    display: inline-block;
    cursor: pointer;
    text-align: center;
}
.menu:after
{
    content: "";
    display: inline-block;
    width: 100%;
    height: 0;
    overflow: hidden;
} 


JS code:
                    function AddMenuItem(id) {
                        var tmp = '<div class="item_menu" onmouseover="MenuOver(this);" onmouseout="MenuOut(this);"><table><tr><td style="vertical-align: top; text-align: left; width: 30px;">';
                        tmp += '<img class="img_menu" alt="111111" src="images/menu/help.png"></td><td style="text-align: left;"><div style="margin-top: 5px;">22241</div></td></tr></table></div>';
                        return '<div class="item_menu" onmouseover="MenuOver(this);" onmouseout="MenuOut(this);"><table><tr><td style="vertical-align: top; text-align: left; width: 30px;"><img class="img_menu" alt="Перемещение" src="images/menu/trip.png"></td><td style="text-align: left;"><div style="margin-top: 5px;">Перемещения</div></td></tr></table></div>';
                    }
         function MenuGen(menu) {
                        var tmp = AddMenuItem(0);
                        for (var i = 1; i < 2; i++) {
                            tmp += AddMenuItem(i);

                        }
                        tmp += AddMenuItem(7) + AddMenuItem(8);
                       $(".menu").html(tmp);
                     }
                    $(function () {
                        MenuGen(0);
                    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Kheben, 2012-03-13
@zBit

Is that how you wanted it?
jsbin.com/izuyuq/2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question