How to write CSS correctly when there are the same properties but with different prefixes for the various browser support?


Tags: css,flexbox

Problem :

If I have properties that are supported by browser with various prefixes, how I should to write the CSS?

Example:

#example {
    display: flex;  
    align-items: center;                    
    justify-content: space-around;
    display: -webkit-flex;
    -webkit-align-items: center;
    -webkit-justify-content: space-around;
    display: -ms-flex;
    -ms-align-items:center;
    -ms-justify-content: space-around;
}   

Or in this way ?

#example {
    display: flex;
    display: -webkit-flex;          
    display: -ms-flex;
    align-items: center;
    -webkit-align-items: center;
    -ms-align-items:center;
    justify-content: space-around;
    -webkit-justify-content: space-around;
    -ms-justify-content: space-around;
}       

Or maybe there is not an order ?



Solution :

I would recommend you to use an online (or natively) tool that will automagically add the css prefixes for all browsers.

If you are using a build system like gulp or grunt, they have plugins that can automatically do this for you.


    CSS Howto..

    How to vertically align data in the center of a table cell in HTML?

    How I can set a different font size for my text by css?

    How can I make sure redundant

    tags do not break styling?

    I would like to have the users change the CSS using an optional panel. How should I do this? [closed]

    Show/Hide elements in a table

    How do you align text of one item in nav?

    How do I remove the double border on this table?

    How to tell if text is overflowing in a table cell in Firefox?

    How do I access HTML elements created by a function? The elements are “undefined” and therefore not CSS apply-able

    How to find the place where font-size for input is set?

    How can I make a DIV background change color on hover if the DIV has a class of “disabled”? [closed]

    how to override unselectable=“on” with css in IE10?

    How to change the style of an active menu with php + css

    How can I write CSS that only applies to specific browsers?

    CSS how to make a fixed height?

    How to trigger css3 rotate effect by clicking?

    when a div is showing do some thing for me and when its hidden stop that , with jquery its possible?

    How to addStyleNames “Multiple css classes” into 1 element in UiBinder in GWT?

    How to make a button CSS change only IF form fields are valid

    How to find out if the user scrolled to the end of a HTML container with jQuery?

    How to select loose text between tags

    How to create a pattern overlay on top of an image

    how to style a horizontal submenu with nested

      How to insert variables in inline CSS rules with pure JavaScript?

      How to transform simple CSS box

      How to create spaces between elements in HTML/CSS

      How to remove a specific (bottom) border from p:row in p:panelGrid?

      How to avoid CSS styles to be applied for particular element

      how to space 4 images equally within a div?

      How do I select immediate children in jQuery [closed]