Some HTML elements, by design, do not accept display changes. Three of these elements:
<button><fieldset><legend>
For example, display: table will not work on fieldset .
Similarly, applying display: inline-flex to a button will be ignored by the browser.
There are other reasonable restrictions. For example, some browsers will ignore overflow: scroll elements on a button . (Tested: Firefox, no scrolling, Chrome, yes)
So, on the bottom line, the button element cannot be a flex container.
An easy fix is ββto wrap the contents of the button in a div and make the div container a flexible container. Or (as pointed out in the comments) use span instead of div as it supports standards compliance.
HTML
<button href="#"> <div> <img src="http://placehold.it/10x10"> <span>Click me</span> </div> </button>
CSS
div { display: flex; justify-content: center; align-items: center; }
Demo
NOTE. Although they cannot be flexible containers, button elements can be flexible.
More details here:
source share