I have a navigation bar with links inside and its around the height I'd like it right now but I want the buttons to be evenly spaced but text-align:justify;
isn't working.
I'm I doing something wrong?
Add
#navigation:after { /* Justify last line */
content: '';
display: inline-block;
width: 100%;
}
#navigation { /* Fix added space */
height: 1.15em;
line-height: 1.15;
}
text-align: justify
doesn't justify the last line. Then, you can add a pseudo-element with width:100%
which will fall to the next line, so the line you want to justify won't be the last one and it will be justified. –
Lachrymator If you add:
text-align-last:justify;
to the #navigation line you will get what you are looking for.
Add
#navigation:after { /* Justify last line */
content: '';
display: inline-block;
width: 100%;
}
#navigation { /* Fix added space */
height: 1.15em;
line-height: 1.15;
}
text-align: justify
doesn't justify the last line. Then, you can add a pseudo-element with width:100%
which will fall to the next line, so the line you want to justify won't be the last one and it will be justified. –
Lachrymator If you are okay without Safari support (as of 2021), there is now a native solution to this, the text-align-last
property:
text-align-last: justify;
Apply this to any text and its last (or only) line will be justified, while the regular text-align
property affects all lines except the last (or none if it's only one line).
This is supported in all major browsers except Safari. Chrome 47+, Edge 12+, Firefox 49+, and Opera. Even IE 5.5+ supports it(!), but text-align: justify;
must also be set to work.
Safari has a bug report to track its status, however it has been the better part of a decade without any updates so Apple really ought to step up its game soon. The bug is marked as "RESOLVED FIXED" but that is not the case.
your links need to have width
to fill the line. specify the with as a %
to fill the line
take a look at this http://getbootstrap.com/components/#nav-justified
© 2022 - 2024 — McMap. All rights reserved.