css - Strange behaviour when using text-align justify/text-justify and right -
i ran 1 ie-specific problem can't wrap head around.
the following html , css can seen live in pen.
:: html
<div id="container"> <div class="dummy">dummy</div> <nav> <div id="right"> <ul> <li>lorem ipsum <img src="http://placehold.it/80x40"> dolor sit amet.</li> <li>anal natrach, ut vas petat, <img src="http://placehold.it/80x40"> doriel dienve.</li> </ul> <div class="dummy">dummy</div> <div class="dummy">dummy</div> </div> </nav> </div>
:: css
/* reset */ * { margin: 0; padding: 0; vertical-align: top; } ul { list-style: none; } /* markup */ #container { line-height: 0; font-size: 0rem; text-align: justify; text-justify: distribute-all-lines; } #container:after { content: ''; display: inline-block; width: 100%; } #container > * { display: inline-block; line-height: 1; font-size: 1rem; text-align: left; text-justify: none; /* not work */ } #container nav { text-align: right; } #right > * { display: inline-block; } /* colors & stuff */ #container { padding: 10px; background: #cfc; } .dummy { padding: 10px; background: #ffc; } #container nav { padding: 10px; background: #ccf; } ul { padding: 10px; background: #fcc; }
so, what's problem?
the content of green div
justified, while each child of div
in turn given text-align: left;
. children are: left dummy div
, bluish nav
.
the nav
contains list (red), , 2 dummies. red list's items text-align set right - , there's lies problem (or @ least, there can see it).
the first image shifted left (and overlays/hides piece of text). second image (and whole second list item) fine. this, however, changes, when changing text. seems if image of longest (meaning widest) item stays should - other images (if create more items) shifted - depending on list item's width, is.
now, why - , how can fix it?
the following things found out far:
- when setting
li { text-align: left; }
image stays fine in between 2 text portions - don't right alignment, of course. - when removing
text-justify
#container
image stays fine well. - setting
text-justify
eitherauto
ornone
not seem work...
once again: this regarding internet explorer (9+).
// edit
in order avoid time being spent on i'm not interested in, i'll post more on i'd have.
the final code must
- keep current/desired functionality (i.e., justified alignment);
- work in major browsers (current version , @ least 1 before that).
the final code must not
- contain floats;
- contain absolute/relative positions.
// edit
here screenshot of desired result (firefox), , 1 of in ie...
change text-justify
distribute (tested in ie10, ie9, chrome, ff):
text-justify: distribute;
check out codepen see in action.
Comments
Post a Comment