Is there a way to use both or either display: grid/-ms-grid into one style sheet or do I have to use an HTML hack or JavaScript to query what type of browser a
The answer by Vadim is pretty much what you should do. But there are a few more CSS tricks you can use to ease your pain.
0. Be sure to read this blog post to decide whether you want to use grids for websites which support IE: https://rachelandrew.co.uk/archives/2016/11/26/should-i-try-to-use-the-ie-implementation-of-css-grid-layout/
If your answer to the previous question is "Yes", read on:
A very trusty companion in cases when you want to write spec-compliant CSS, but still support IE is the @supports() at-rule. I use it to use the more advanced grid properties such as grid-gaps, etc:
.card-list {
grid-row: 4;
grid-column: 1 / 3;
padding: 1.5vh 1vh;
display: grid;
grid-template-rows: 1fr 1fr;
grid-template-columns: 1fr 1fr;
}
.card {
margin-bottom: 1vh;
}
.card:nth-of-type(odd) { /* takes care of IE */
margin-right: 1vh;
grid-column: 1;
}
.card:nth-of-type(even) {
grid-column: 2;
}
@supports(grid-gap: 1vh) { /* still using standard code! */
.card-list {
grid-gap: 1vh;
}
.card {
margin-right: 0;
margin-bottom: 0;
}
}