W3.CSS

W3.CSS หน้าแรก W3.CSS แนะนำ W3.CSS สี คอนเทนเนอร์ W3.CSS แผง W3.CSS เส้นขอบ W3.CSS การ์ด W3.CSS ค่าเริ่มต้นของ W3.CSS แบบอักษร W3.CSS W3.CSS Google W3.CSS Text W3.CSS รอบ W3.CSS แพ็ดดิ้ง W3.CSS Margins จอแสดงผล W3.CSS ปุ่ม W3.CSS W3.CSS หมายเหตุ คำคม W3.CSS การแจ้งเตือน W3.CSS ตาราง W3.CSS รายการ W3.CSS W3.CSS รูปภาพ อินพุต W3.CSS ป้าย W3.CSS แท็ก W3.CSS ไอคอน W3.CSS W3.CSS ตอบสนอง เค้าโครง W3.CSS ภาพเคลื่อนไหว W3.CSS เอฟเฟกต์ W3.CSS W3.CSS บาร์ ดรอปดาวน์ W3.CSS หีบเพลง W3.CSS W3.CSS การนำทาง แถบด้านข้าง W3.CSS แท็บ W3.CSS การแบ่งหน้า W3.CSS แถบความคืบหน้า W3.CSS สไลด์โชว์ W3.CSS W3.CSS โมดอล เคล็ดลับเครื่องมือ W3.CSS W3.CSS กริด รหัส W3.CSS ตัวกรอง W3.CSS W3.CSS Trends กรณี W3.CSS W3.CSS วัสดุ การตรวจสอบ W3.CSS เวอร์ชัน W3.CSS W3.CSS มือถือ

W3.CSS สี

คลาสสี W3.CSS W3.CSS วัสดุสี W3.CSS Color Flat UI W3.CSS Color Metro UI W3.CSS สี Win8 W3.CSS Color iOS W3.CSS แฟชั่นสี ไลบรารีสี W3.CSS W3.CSS แบบแผนสี ธีมสี W3.CSS W3.CSS เครื่องกำเนิดสี

การสร้างเว็บ

แนะนำเว็บ เว็บ HTML เว็บ CSS JavaScript ของเว็บ เค้าโครงเว็บ เว็บแบนด์ เว็บจัดเลี้ยง เว็บร้านอาหาร สถาปนิกเว็บ

ตัวอย่าง

ตัวอย่าง W3.CSS W3.CSS สาธิต เทมเพลต W3.CSS

อ้างอิง

การอ้างอิง W3.CSS ดาวน์โหลด W3.CSS

หีบเพลง W3.CSS


คลิกที่ปุ่ม "ส่วนเปิด" ด้านล่างเพื่อดูว่าหีบเพลงทำงานอย่างไร:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Accordion with Images:

Alps

French Alps


หีบเพลง

หีบเพลงใช้เพื่อแสดง (และซ่อน) เนื้อหา HTML

ใช้ คลาส w3-hideเพื่อซ่อนเนื้อหาหีบเพลง

ใช้ปุ่มประเภทใดก็ได้เพื่อเปิดและปิดเนื้อหา:

ตัวอย่าง

<button onclick="myFunction('Demo1')" class="w3-button w3-block w3-left-align">
Open Section 1</button>

<div id="Demo1" class="w3-container w3-hide">
  <p>Some text..</p>
</div>

<script>
function myFunction(id) {
  var x = document.getElementById(id);
  if (x.className.indexOf("w3-show") == -1) {
    x.className += " w3-show";
  } else {
    x.className = x.className.replace(" w3-show", "");
  }
}
</script>

ทั้งองค์ประกอบที่ใช้เปิดหีบเพลงและเนื้อหาของหีบเพลงสามารถเป็นองค์ประกอบ HTML ใดก็ได้


หีบเพลงกับ Dropdown

ตารางนี้แสดงความแตกต่างระหว่างหีบเพลงกับดรอปดาวน์:

หีบเพลงหล่นลง
เนื้อหาผลักเนื้อหาของหน้าลง เนื้อหาวางทับเนื้อหาหน้าที่มีอยู่
เนื้อหามักจะกว้าง 100% เนื้อหากว้าง 160px (ค่าเริ่มต้น)
มักใช้เปิดหลายส่วน มักใช้เปิดส่วนเดียว

หีบเพลง

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

ดรอปดาวน์



ปุ่มหีบเพลง

คุณสามารถใช้องค์ประกอบ HTML ใด ๆ เพื่อเปิดเนื้อหาหีบเพลง เราต้องการปุ่มที่มี คลาส w3-blockเพื่อขยายความกว้างทั้งหมดของหน้า (ความกว้าง 100%)

จำไว้ว่าปุ่มใน W3.CSS จะอยู่กึ่งกลางตามค่าเริ่มต้น ใช้ คลาส w3-left-alignหากคุณต้องการให้จัดชิดซ้ายแทน อย่างไรก็ตาม คุณไม่จำเป็นต้องปฏิบัติตามแนวทางของเรา หีบเพลงจะดูดีไม่ว่าจะด้วยวิธีใด:

Lorem ipsum...

Lorem ipsum...

Centered content as well!

ตัวอย่าง

<button onclick="myFunc('Demo1')" class="w3-button">
Normal button</button>

<div id="Demo1" class="w3-hide">
  <p>Lorem ipsum...</p>
</div>

<button onclick="myFunc('Demo2')" class="w3-button w3-block w3-left-align w3-green">
Left aligned and full-width</button>

<div id="Demo2" class="w3-hide">
  <p>Lorem ipsum...</p>
</div>

<button onclick="myFunc('Demo3')" class="w3-btn w3-block w3-red">
Centered and full-width</button>

<div id="Demo3" class="w3-hide w3-center">
  <p>Centered content as well!</p>
</div>


ปุ่มหีบเพลงที่ใช้งาน

ใช้ JavaScript เพื่อเน้นหีบเพลงที่เปิดอยู่ (คลิกที่):

Some text..

Some other text..

ตัวอย่าง

// Add the w3-red class to all opened accordions
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
  x.className += " w3-show";
  x.previousElementSibling.className += " w3-red";
} else {
  x.className = x.className.replace("w3-show", "");
  x.previousElementSibling.className =
  x.previousElementSibling.className.replace("w3-red", "");
}


ความกว้างของหีบเพลง

โดยค่าเริ่มต้น ความกว้างของบล็อกคือ 100% หากต้องการแทนที่สิ่งนี้ ให้เปลี่ยนคุณสมบัติความกว้าง CSS ของคอนเทนเนอร์หีบเพลง:

Some text..

Some text..

Some text..

Some text..

ตัวอย่าง

<div class="w3-light-grey" style="width:50%">
  <button onclick="myFunction('Demo1')" class="w3-button w3-block">
    50%
  </button>
  <div id="Demo1" class="w3-hide">
    <p>Some text..</p>
  </div>
</div>


เนื้อหาหีบเพลง

หีบเพลงที่มีลิงก์:

ตัวอย่าง

<button onclick="myFunction('Demo1')" class="w3-button w3-block w3-left-align">
Accordion</button>

<div id="Demo1" class="w3-hide">
  <a href="#" class="w3-button w3-block w3-left-align">Link 1</a>
  <a href="#" class="w3-button w3-block w3-left-align">Link 2</a>
  <a href="#" class="w3-button w3-block w3-left-align">Link 3</a>
</div>

หีบเพลงเป็นรายการ:
  • Jill
  • อีฟ
  • อดัม

ตัวอย่าง

<button onclick="myFunction('Demo1')" class="w3-button w3-block w3-left-align">
Accordion</button>

<div id="Demo1" class="w3-hide">
  <ul class="w3-ul">
    <li>Jill</li>
    <li>Eve</li>
    <li>Adam</li>
  </ul>
</div>

หีบเพลงภายในแถบด้านข้าง (คุณจะได้เรียนรู้เพิ่มเติมเกี่ยวกับแถบด้านข้างในภายหลัง):

ตัวอย่าง

<div class="w3-sidebar w3-bar-block w3-light-grey w3-card" style="width:200px;">
  <a href="#" class="w3-bar-item w3-button">Link 1</a>
  <a href="#" class="w3-bar-item w3-button" onclick="myAccFunc()">Accordion</a>
  <div id="demoAcc" class="w3-hide">
    <a href="#" class="w3-bar-item w3-button">Link</a>
    <a href="#" class="w3-bar-item w3-button">Link</a>
  </div>
  <div class="w3-dropdown-click">
    <a href="#" class="w3-bar-item w3-button" onclick="myDropFunc()">Dropdown</a>
    <div id="demoDrop" class="w3-dropdown-content">
      <a href="#" class="w3-bar-item w3-button">Link</a>
      <a href="#" class="w3-bar-item w3-button">Link</a>
    </div>
  </div>
  <a href="#" class="w3-bar-item w3-button">Link 2</a>
  <a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>


หีบเพลงเคลื่อนไหว

ใช้คลาส w3-animate- เพื่อเฟด ซูม หรือเลื่อนในเนื้อหาหีบเพลง:

ตัวอย่าง

<div id="Demo1" class="w3-hide w3-animate-zoom">