Wie kann ich die 3 Label-Buttons (Tab 1, 2 und 3) in der Mitte über dem Inhalt platzieren? Sie sind jetzt nach links ausgerichtet. Darüber hinaus würde ich auch eine Lösung schätzen, um den Inhalt zu verstecken, falls ein Benutzer auf seinem Telefon ist. Ich hoffe, dass das nicht zu schwer ist.Wie kann ich Tab-Labels in CSS zentrieren?
.tabs {
position:absolute; bottom:0;
display: flex;
flex-wrap: wrap;
}
.tabs label {
order: 1;
display: block;
padding: 1rem 2rem;
margin-right: 0.2rem;
cursor: pointer;
background: #90CAF9;
font-weight: bold;
transition: background ease 0.2s;
}
.tabs .tab {
order: 99;
flex-grow: 1;
width: 100%;
display: none;
padding: 1rem;
background: #fff;
}
.tabs input[type="radio"] {
display: none;
}
.tabs input[type="radio"]:checked + label {
background: #fff;
}
.tabs input[type="radio"]:checked + label + .tab {
display: block;
}
@media (max-width: 45em) {
.tabs .tab,
.tabs label {
order: initial;
}
.tabs label {
width: 100%;
margin-right: 0;
margin-top: 0.2rem;
}
}
<div class="tabs">
\t \t <input type="radio" name="tabs" id="tabone" checked="checked">
\t \t <label for="tabone">Tab One</label>
\t \t <div class="tab">
\t \t \t <h1>Tab One Content</h1>
\t \t \t <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
\t \t </div>
\t \t <input type="radio" name="tabs" id="tabtwo">
\t \t <label for="tabtwo">Tab Two</label>
\t \t <div class="tab">
\t \t \t <h1>Tab Two Content</h1>
\t \t \t <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
\t \t </div>
\t \t <input type="radio" name="tabs" id="tabthree">
\t \t <label for="tabthree">Tab Three</label>
\t \t <div class="tab">
\t \t \t <h1>Tab Three Content</h1>
\t \t \t <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
\t \t </div>
\t </div>
Hinzufügen zu '.tabs label'' text-align: center' –