I'm trying to work with an example of a css grid. But when I use it with Aurelia repeater it renders odd in the browser. I tried to isolate everything into only simple styles but still the same problem. First it is the repeater and then I have hard coded the exact result of the repeater below. Notice that it doesn't matter which order you place them.
Tried to create an example over here: https://gist.run/?id=0dbb9921dd8997e0ddbbeeba8bca9dd6
The only thing you need to put in your app.js is:
export class App {
constructor() {
this.styleString = "width:25%;display:inline-block;min-height:1px;vertical-align:top;padding-left:20px;margin-right:-.25em;box-sizing:border-box;";
}
}
And in you app.html:
<template>
<div>
<div repeat.for="i of 4" style="background:${i%2==0?'red':'green'};${styleString}">
${i}
</div>
</div>
<div>
<div style="background:red;${styleString}">
0
</div>
<div style="background:green;${styleString}">
1
</div>
<div style="background:red;${styleString}">
2
</div>
<div style="background:green;${styleString}">
3
</div>
</div>
</template>
Can anyone clarify what I'm doing wrong?
EDIT
Sorry. The odd behavior is that in my browser the width of the four columns is not as wide as the four columns I have hard coded. It is not full length.
I am able to reproduce the error if I copy the OUTER HTML of the outer div in developer tools and paste it into my app.html. But if I format that correctly in terms of indentation and correct line breaks it renders what in my opinions is correctly.
EXPLANATION
As Fabio points out in his comment it is the white space that is the difference. The css grid I'm evaluating is taking this into account and adds this style margin-right:-.25em;
because it is expecting you to have white spaces between your divs. You can actually read about that in the link provided by Andrew.
The simplest solution might be to just add a class if I generate these grid columns with Aurelia repeater that overrides the margin-right
and set it to zero.