I have this simple div with a button inside of it. justify-content: center;
funktioniert Firefox und Chrome, aber funktioniert nicht auf IE 11:Warum nicht gerechtfertigt-Inhalt: Center Arbeit in IE?
#div {
height: 200px;
width: 50px;
border: 1px solid black;
display: flex;
flex: 0 0 auto;
align-items: center;
justify-content: center;
}
#button {
height: 50px;
width: 200px;
min-width: 200px;
border: 1px solid black;
background-color: red;
}
<div id="div">
<button id="button">HELLO</button>
</div>
Mein Ziel ist es, dass, wenn ich transform
mit rotate(90deg)
oder rotate(270deg)
, the button will fit into the div:
#div {
height: 200px;
width: 50px;
border: 1px solid black;
display: flex;
flex: 0 0 auto;
align-items: center;
justify-content: center;
}
#button {
height: 50px;
width: 200px;
min-width: 200px;
border: 1px solid black;
background-color: red;
transform: rotate(90deg);
}
<div id="div">
<button id="button">HELLO</button>
</div>
Die height
und width
der div
und button
sind immer die gleichen, sind aber anpassbar.
So viel wie möglich, ich bevorzuge keine Verpackung Elemente.
Ich dachte, flex-Richtung, um die Hauptachse für die Eltern zugeordnet. Wenn Sie also auf Zeile setzen, sollte 'justify-content: center' den Inhalt entlang der horizontalen Achse zentrieren. Wenn Sie die Spalte explizit angeben, sollte der Inhalt entlang der Vertikalen zentriert werden. IE11 scheint "justify-content: center" in einer Zeile nicht zu respektieren. – ChrisPEditor