Answer the question
In order to leave comments, you need to log in
How to layout a menu like flex-box (justify-content: space-between)?
So it goes. I'm already used to flex, and then suddenly I needed support for old browsers.
But I don't even remember laying out such menus without flex: The point
is that the empty space should be evenly centered between menu items, and the first and last items should be adjacent to the edges.
Well, there can be 3 or 4 menu items. This adds problems, because. under a constant number of points, you can still make up.
Answer the question
In order to leave comments, you need to log in
Do an inlinde-block with text-align:justify
Here is the description
You can solve it with js. I will write code in jquery:
var mainWidth = $('.container').width();
var menuWidth = 0;
var countItems = 0;
$('nav li').each(function() {
menuWidth += $(this).width();
countItems++;
});
countItems--;
var marginItems = (mainWidth-menuWidth)/countItems;
$('nav li').css('margin-right', marginItems);
$('nav li:last-child').css('margin-right', 0);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question