我目前正在爲我的易趣帳戶創建一個列表模板,所以如果可能的話,我需要創建一個不使用JS的解決方案。我試圖使用無線電黑客切換在「tabinfo」div內查看的文本,但我的無線電和我想要更改的「display:」屬性的文本位於不同的div中。是否可以使用純粹的CSS選擇器來選擇#text?我使用的是引導佈局和已經創建了下面的HTML代碼:我可以影響div之外的元素嗎?我目前純粹使用CSS?
<div class="col-xs-2">
<input id="tab1" type="radio" name="tabs">
<label for="tab1">Foo</label>
</div>
<div class="col-xs-2">
<input id="tab2" type="radio" name="tabs">
<label for="tab2">Bar</label>
</div>
<div class="col-xs-2">
<input id="tab3" type="radio" name="tabs" checked>
<label for="tab3">Foo Bar</label>
</div>
<div class="col-xs-12">
<div class="tabinfo">
<div id="text1">
</div>
<div id="text2">
</div>
<div id="text3">
</div>
</div>
</div>
下面CSS:
label {
border: solid;
border-top-right-radius: 10px;
border-top-left-radius: 10px;
border-bottom: none;
border-color: rgb(211,211,205);
border-width: 2px;
color: rgb(12,174,175);
background-color: rgb(247,247,247);
}
input:checked + label {
background-color: #fff;
color: rgb(94,94,94);
}
label:hover {
cursor: pointer;
}
.tabinfo {
border: solid;
border-color: rgb(211,211,205);
border-width: 2px;
border-top-right-radius: 10px;
}
#tab1:checked ~ .col-xs-12 .tabinfo #text1,
#tab2:checked ~ .col-xs-12 .tabinfo #text2,
#tab3:checked ~ .col-xs-12 .tabinfo #text3 {
display: block!important;
}
正如你可能已經猜到了,上面並沒有因爲#texts和工作#tabs位於不同的div中。有沒有任何解決方法或任何解決方案沒有打破引導佈局?提前致謝。
應該每個無線輸入影響什麼具體的「文」? HTML可以改變嗎?而且,順便說一下,只有一個無線電輸入,共享一個共同的'name'屬性的組可以'檢查'。 –
對不起,我只是寫了上面的代碼。每個編號選項卡都會影響數字文本,即如果選中#tab1,將顯示#text1。人。只要不破壞引導程序佈局,HTML就可以被更改。 –