I'm scratching my head around trying to reproduce this, apparently, simple template:
I found tons of answer quite reproducing this (like here), but it never fits my needs because:
I want my text to touch borders of the container. (Kind like first text of a line aligned to the left, and last text of line aligned to the right, but keeping same spacing between text)
I don't want to use a wrapper per line (but I'm not limited in terms of wrapper per item), because number of item per line can change on window resize.
Need to works on IE11
Here an example, I'd like the number 6
to be "stuck" to the right border and keep equal spacing.
.container{
border: 1px solid red;
display: flex;
justify-content: space-between;
width: 300px;
flex-wrap: wrap;
}
.container::after {
content: "";
flex: auto;
}
p{
min-width: 16.666%;
}
<div class="container">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
</div>
Above the correct visual result but it use lines container, which I don't want.
.container{
border: 1px solid red;
width: 300px;
}
.line{
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
}
.line:last-child {
justify-content: flex-start;
}
.line:last-child p{
width: 16.6666%;
}
<div class="container">
<div class="line">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</div>
<div class="line">
<p>7</p>
<p>8</p>
<p>9</p>
</div>
</div>
For information, grid's solution tested weren't working on IE11, like this one:
.container{
border: 1px solid red;
display: grid;
grid-template-columns:repeat(6,auto);
justify-content: space-between;
width: 300px;
}
<div class="container">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
</div>
` stuck the right border, not the number `6`, it would if it was `text-align: right`, but then equal spacing would be lost. Please look at the screen given in the description to understand the expected visual result
– Allan Raquin Dec 03 '19 at 10:30