- CSS ย่อมาจาก Cascading Style Sheet คือภาษาที่ใช้เป็นส่วนของการจัดรูปแบบการแสดงผลเอกสาร HTML โดยที่ CSS กำหนดกฏเกณฑ์ในการระบุรูปแบบ
- Navigation Tabs เหมาะสำหรับแอ็พพลิเคชันเว็บเพจเดียวหรือสำหรับเว็บเพจที่สามารถแสดงหัวข้อต่างๆได้
- ตัวอย่างโค้ด ฟังก์ชันจะซ่อนองค์ประกอบทั้งหมดด้วยชื่อคลาส "name" (display = "none") และแสดงองค์ประกอบที่มีชื่อเมืองที่ระบุ (display = "block");
[list]รูปแบบโค้ด ส่วนของแท็บ[/list][/b][/color]
โค้ด: เลือกทั้งหมด
<div id="Name_id" class="w3-container name"> <h2>Edit_text</h2> <p>Edit_text</p> </div>
- อธิบายโค้ด
- - Name_id คือ ชื่อไอดี
- Edit_text คือ ข้อความที่ต้องการแสดง
- - Name_id คือ ชื่อไอดี
โค้ด: เลือกทั้งหมด
<div class="w3-bar w3-black"> <button class="w3-bar-item w3-button" onclick="functionName('Name_id')">Edit_text</button> </div>
- อธิบายโค้ด
- - Name_id คือ ชื่อไอดี
- Edit_text คือ ข้อความที่ต้องการแสดงบนแท็บส์
- functionName คือ ชื่อฟังก์ชั่น
- - Name_id คือ ชื่อไอดี
โค้ด: เลือกทั้งหมด
<script> function functionName(Name) { var i; var x = document.getElementsByClassName("name"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } document.getElementById(Name).style.display = "block"; } </script>
- อธิบายโค้ด
- - functionName คือ ชื่อฟังก์ชั่น
- ฟังก์ชัน function_name () คือ เมื่อผู้ใช้คลิกที่ปุ่มใดปุ่มหนึ่งในเมนู
- - functionName คือ ชื่อฟังก์ชั่น
โค้ด: เลือกทั้งหมด
<!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <body> <div class="w3-container"> <h2>Tabs</h2> <p>Hello</p> </div> <div class="w3-bar w3-black"> <button class="w3-bar-item w3-button" onclick="openName('Jam')">Jam</button> <button class="w3-bar-item w3-button" onclick="openName('PaoPao')">PaoPao</button> <button class="w3-bar-item w3-button" onclick="openName('Kim')">Kim</button> </div> <div id="Jam" class="w3-container name"> <h2>Jam</h2> <p>She is beautiful.</p> </div> <div id="PaoPao" class="w3-container name" style="display:none"> <h2>PaoPao</h2> <p>She is rich. </p> </div> <div id="Kim" class="w3-container name" style="display:none"> <h2>Kim</h2> <p>She is kind.</p> </div> <script> function openName(Name) { var i; var x = document.getElementsByClassName("name"); for (i = 0; i < x.length; i++) { x[i].style.display = "none"; } document.getElementById(Name).style.display = "block"; } </script> </body> </html>
- 1. เมื่อยังไม่ได้คลิกจะอยู่ที่ tab แรก (Jam) 2. เมื่อคลิกที่แท็บส์ที่ 2 (PaoPao) 3. เมื่อคลิกที่แท็บส์ที่ 3 (Kim)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
_____________________________________________________________________________________________
บทความนี้เเป็นบทความที่จัดทำขึ้นเพื่อเนะนำเครื่องมือช่วยสำหรับนักพัฒนา CSS,HTML ซึ่งเป็นความรู้พื้นฐานในการพัฒนา PHP ต่อไป เเละขอเเนะนำความรู้ที่เกี่ยวข้องกับ HTML , CSS โดยสามารถศึกษาได้จากบทเรียน PHP ได้ที่นี่ เพื่อเพิ่มความเข้าใจในการใช้งานเครื่องมือต่างๆ ค่ะ
_____________________________________________________________________________________________
----------------------------------------------------------------------------------------------------------------------------------------------------------------