This question already has answers here:
CSS Grid Layout not working in IE11 even with prefixes
(4 answers)
Browser support for CSS Grid
(2 answers)
Closed 5 years ago.
I'm trying to use the CSS grid to make some columns on my page, but I cannot get it to work on IE.
Here is the CSS I have and it works fine on Chrome and Firefox.
.wrapper {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
grid-column-gap: 15px;
grid-row-gap: 10px;
grid-auto-flow: dense;
margin: 1em auto;
padding-left: 10px;
padding-right: 15px;
font-size: 12px;
}
Is it possible to convert this CSS to work on IE?
You might be able to get partial support for CSS grid in IE >= 11 with the -ms- prefix. Reference.
IMO you can write fallback styles using flex to support older browsers and yet get the advantage of CSS grid on newer ones.
Related
This question already has an answer here:
Why is 'position: sticky' not working with Core UI's Bootstrap CSS
(1 answer)
Closed 5 months ago.
i have a weird situation that is happening only inside of a wordpress site installation. where i need to have a two columns grid and being the first one a sticky one on the top.
You can check the test page at: https://dev.mentepresente.pt/test/
the css is super simple and it works out of wordpress:
.wrapper {
display: grid;
grid-template-columns: 50px 200px;}
.item1 {
grid-column: 1;
align-self: start;
position: sticky;
top: 0;}
.item2 {
grid-column: 2;}
Does any one know the reason why this is happening?
The issue was because i had a parent element with overflow: hidden; that was messing up with with the sticky position
This question already has answers here:
CSS Grid Row Height Safari Bug
(2 answers)
Closed 1 year ago.
I have built a grid based photo layout for this website:
https://lsiemoneit.de/digital-identity/photos.html
It works just like I expected in Firefox and Chrome but the layout breaks in Safari.
I have attached a codepen that replicates and isolates that behaviour down below. Somehow in Safari the grid-row gets stretched to 100% while in Chrome and Safari it keeps the aspect ratio. Has this something to do with how Safari handles object-fit: contain?
https://codepen.io/lkssmnt-the-lessful/pen/oNBLZyZ
.photos-container {
width: 100%;
display: grid;
grid-column-gap: 0.5rem;
grid-row-gap: 2rem;
grid-template-columns: repeat(12, 1fr);
}
.photos-container img {
height: 100%;
width: 100%;
object-fit: cover;
}
Thanks for your help!
So apparently putting each and every image in a container of its one "fixes" that behaviour for Safari.
More information about that behaviour can be found here:
https://stackoverflow.com/a/44773109/7243348
This question already has answers here:
What is difference between justify-self, justify-items and justify-content in CSS grid?
(4 answers)
Closed 4 years ago.
I am new in CSS-Grid topic, I created a header for a website with the help of GRID, I created header with logo , navBar , searchbar , button with grid
.header {
height: 60px;
margin-bottom: 20px;
display: grid;
grid-template-columns: 1fr 3fr 0.1fr 0.5fr;
grid-auto-rows: 70px;
align-items:center;
justify-items: center;
}
Now these last two properties align-items and justify-items are apply for all ie, for logo , navbar , searchbar , button.
My problem is :I want to override this justify-items:center property
to justify-items:flex-start for navBar only. So who can I do this?
Here is screenshot of header:
If you're writing in pure CSS, you can add another line that is more specific, like this
.header .navBar {
justify-items:flex-start;
}
This will take priority over the previous css style you have. Generally speaking the more specific styles are applied first.
I am trying to use grid layouts but IE 11 and Edge(15 and below) don't support current implementation of grids. I been reading you should have a fall back design(usually just your mobile layout) which I would be using flexbox.
I don't really care about anything less than IE 11.
I know I can use the #supports not (display: grid) and stick my flexbox code in that block and this would work for Edge but IE 11 does not support the #support tag.
I read for IE 11 I can use #media all and (-ms-high-contrast: none), (-ms-high-contrast: active)
but this does not work in edge so I would have to duplicate my flexbox css code twice. Once in the #media check and one in #supports.
I would like to merge the check into one if possible.
Example:
/* use this for anything that supports grid layout */
#supports (display: grid){
.container {
display: grid;
}
}
/* need to wrap this around with something that will only render on IE 11 or Edge 15 and below */
.container {
display: flex;
}
There is grid implementation specifically for IE10, 11 and Edge < 16. Here is how to handle both IE and Grid supporting browsers:
In your Grid you need to setup both MS grid and New grid:
.my-grid {
display: -ms-grid;
display: grid;
-ms-grid-rows: 500px auto auto;
grid-template-rows: 500px auto auto;
-ms-grid-columns: 1fr 400px;
grid-template-columns: 1fr 400px;
}
Then you need to use -ms vendor prefixes on each of your section as well as regular non prefixed ones. Basically you will implement two grids. If you only want to use flex on IE as you mentioned then:
.my-grid {
display: flex;
display: grid;
grid-template-rows: 500px auto auto;
grid-template-columns: 1fr 400px;
/* since IE doesn't support display: grid; the last two lines won't matter */
}
My recommendation is:
Mobile first using flex
Grid for new grid supported in all major browsers
MS Grid (does not support gutters from new grid)
NOTES: Microsoft made the first grid implementation, after that other Browsers changed the Spec and after a few years made their own implementation. It took MS a few years to match the new spec on IE Edge 16. That's why there is a MS grid implementation, and a grid one.
This question already has answers here:
Flexbox code working on all browsers except Safari. Why?
(3 answers)
Closed 5 years ago.
The chart below works on Chrome and Firefox, but Safari is shrinking the width of the boxes. This is also happening on mobile clients. I'm including the css for the chart container and a codepen to the complete markup and css.
https://codepen.io/juancho1/pen/akyNmp
#chart-container{
width: 100%;
height: auto;
border: 1px solid #39c3ec;
/*display: -webkit-box;*/
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
overflow-x: scroll !important;
}
I'm hoping someone has come across this specific issue before. While looking for a possible solution I saw that Safari has some issues with flexbox, and tried most of the solutions I've seen. It may be also related to the flex direction.
I'd appreciate any tips anyone may have!
Thanks
Update
As much as I love the upvotes I've been getting randomly, I've realized I made a pretty big mistake in my original post. The default flex value is 0 1 auto not 1 0 auto. However, this only adds to the reasoning behind why setting flex-shrink to 0 would keep flex items from shrinking, it just doesn't explain why they weren't shrinking in all browsers.
Original Post
I've ran into this issue before. On most other browsers, flex is automatically set to 1 0 auto, which is short for saying flex-grow: 1; flex-shrink: 0; flex-basis: auto;. flex-shrink: 0; should prevent the boxes from shrinking, but it seems safari does not automatically set this property. Simply set flex-shrink to 0 on your flex items and they will not shrink anymore.