我想用顯示:彎曲與線類改變的div的順序,但我想保持這樣的標籤導航順序:A→B→C→ D.Flexbox的順序和Tab鍵導航
正如你可以在片段中看到的,第一個例子工作正常(DOM序列與Order相同),但在第二個例子中,該選項卡遵循DOM序列。
沒有使用javascript的機會?
.container {
display: flex;
flex-direction: column;
}
.line {
padding: 5px;
border: 1px solid gray;
margin-bottom: 5px;
}
.line span {
margin-left: 7px;
}
<h2>
Tabbing navigation OK
</h2>
<div class="container">
<div class="line" style="order: 1;"><input value="A"><span>1st div - Order: 1</span></div>
<div class="line" style="order: 2;"><input value="B"><span>2nd div - Order: 2</span></div>
<div class="line" style="order: 3;"><input value="C"><span>3rd div - Order: 3</span></div>
<div class="line" style="order: 4;"><input value="D"><span>4th div - Order: 4</span></div>
</div>
<h2>
Tabbing navigation KO
</h2>
<div class="container">
<div class="line" style="order: 1;"><input value="A"><span>1st div - Order: 1</span></div>
<div class="line" style="order: 4;"><input value="C"><span>2nd div - Order: 4</span></div>
<div class="line" style="order: 3;"><input value="C"><span>3rd div - Order: 3</span></div>
<div class="line" style="order: 2;"><input value="B"><span>4th div - Order: 2</span></div>
</div>
的jsfiddle鏈接here。
在此先感謝
我能想到的唯一方法就是使用'tabindex'。 –