လုပ်နည်း - Tab Headers
CSS နှင့် JavaScript ဖြင့် တက်ဘ် ခေါင်းစီးများကို ဖန်တီးနည်းကို လေ့လာပါ။
တက်ဘ် ခေါင်းစီးများ
သင့်လျော်သော ခေါင်းစီးကိုပြသရန် "မြို့" ခလုတ်များကို နှိပ်ပါ။
တိုကျို
တိုကျိုသည် ဂျပန်နိုင်ငံ၏ မြို့တော်ဖြစ်သည်။
Togglable Tab Headers ကို ဖန်တီးပါ။
အဆင့် 1) HTML ကိုထည့်ပါ
ဥပမာ
<div id="London" class="tabcontent">
<h1>London</h1>
<p>London is the
capital city of England.</p>
</div>
<div id="Paris" class="tabcontent">
<h1>Paris</h1>
<p>Paris is the capital of France.</p>
</div>
<div id="Tokyo" class="tabcontent">
<h1>Tokyo</h1>
<p>Tokyo is the
capital of Japan.</p>
</div>
<div id="Oslo" class="tabcontent">
<h1>Oslo</h1>
<p>Oslo is the capital of Norway.</p>
</div>
<button class="tablink" onclick="openCity('London', this, 'red')" id="defaultOpen">London</button>
<button class="tablink" onclick="openCity('Paris', this,
'green')">Paris</button>
<button class="tablink" onclick="openCity('Tokyo',
this, 'blue')">Tokyo</button>
<button class="tablink" onclick="openCity('Oslo',
this, 'orange')">Oslo</button>
သီးခြားတဘ်အကြောင်းအရာကိုဖွင့်ရန် ခလုတ်များဖန်တီးပါ။ <div> ဒြပ်စင်များအားလုံးကို class="tabcontent"
မူရင်းအတိုင်း ဝှက်ထားသည် (CSS & JS)။ အသုံးပြုသူက ခလုတ်တစ်ခုကို နှိပ်လိုက်သောအခါ - ၎င်းသည် ဤခလုတ် "ကိုက်ညီသော" တက်ဘ်အကြောင်းအရာကို ဖွင့်ပေးလိမ့်မည်။
အဆင့် 2) CSS ကိုထည့်ပါ
ခလုတ်များနှင့် တက်ဘ်အကြောင်းအရာကို ပုံစံထုတ်ပါ-
ဥပမာ
/* Style the tab buttons */
.tablink {
background-color: #555;
color: white;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
font-size: 17px;
width: 25%;
}
/* Change background color of buttons on hover */
.tablink:hover {
background-color: #777;
}
/* Set default styles for tab content */
.tabcontent
{
color: white;
display: none;
padding: 50px;
text-align: center;
}
/* Style
each tab content individually */
#London {background-color:red;}
#Paris {background-color:green;}
#Tokyo {background-color:blue;}
#Oslo {background-color:orange;}
အဆင့် 3) JavaScript ကိုထည့်ပါ။
ဥပမာ
function openCity(cityName, elmnt, color) {
// Hide all
elements with class="tabcontent" by default */
var i,
tabcontent, tablinks;
tabcontent =
document.getElementsByClassName("tabcontent");
for (i =
0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Remove the background color of all tablinks/buttons
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].style.backgroundColor = "";
}
// Show the specific tab content
document.getElementById(cityName).style.display = "block";
// Add the specific color to the button used to open the tab content
elmnt.style.backgroundColor = color;
}
// Get the element with id="defaultOpen"
and click on it
document.getElementById("defaultOpen").click();
အကြံပြုချက်- How To - Tabs ကိုလည်း စစ်ဆေးကြည့်ပါ ။