Bootstrap 4 บทช่วยสอน

BS4 HOME BS4 เริ่มต้น BS4 คอนเทนเนอร์ BS4 Grid Basic BS4 วิชาการพิมพ์ BS4 สี ตาราง BS4 BS4 รูปภาพ BS4 Jumbotron การแจ้งเตือน BS4 ปุ่ม BS4 กลุ่มปุ่ม BS4 ป้าย BS4 แถบความคืบหน้า BS4 BS4 Spinners BS4 การแบ่งหน้า BS4 รายการกลุ่ม การ์ด BS4 BS4 ดรอปดาวน์ BS4 ยุบ BS4 Navs BS4 Navbar แบบฟอร์ม BS4 อินพุต BS4 กลุ่มอินพุต BS4 BS4 แบบฟอร์มที่กำหนดเอง BS4 ม้าหมุน BS4 โมดอล เคล็ดลับเครื่องมือ BS4 BS4 ป๊อปโอเวอร์ BS4 ขนมปังปิ้ง BS4 Scrollspy BS4 ยูทิลิตี้ BS4 Flex ไอคอน BS4 วัตถุสื่อ BS4 ตัวกรอง BS4

Bootstrap 4 Grid

ระบบกริด BS4 BS4 ซ้อน/แนวนอน BS4 Grid XSmall BS4 กริดขนาดเล็ก BS4 กริดขนาดกลาง BS4 กริดขนาดใหญ่ BS4 Grid XLarge ตัวอย่างกริด BS4

Bootstrap 4 อื่นๆ

เทมเพลตพื้นฐาน BS4 แบบฝึกหัด BS4 แบบทดสอบ BS4

Bootstrap 4 อ้างอิง

ทุกชั้นเรียน JS Alert ปุ่ม JS JS Carousel JS ยุบ JS Dropdown JS Modal JS Popover JS Scrollspy JS แท็บ JS Toasts JS Tooltip


Bootstrap JS Toasts


คลาส CSS ของขนมปัง

คอมโพเนนต์ Toast เป็นเหมือนกล่องแจ้งเตือนที่แสดงเพียงไม่กี่วินาทีเมื่อมีบางอย่างเกิดขึ้น (เช่น เมื่อผู้ใช้คลิกปุ่ม ส่งแบบฟอร์ม เป็นต้น)

สำหรับบทแนะนำเกี่ยวกับ Toasts โปรดอ่านBootstrap Toast Tutorialของเรา

Class Description Example
.toast Creates the toast
.toast-header Creates the toast header
.toast-body Creates the toast body

เปิดใช้งานผ่าน JavaScript

ขนมปังปิ้งต้องเริ่มต้นด้วย jQuery: เลือกองค์ประกอบที่ระบุและเรียกtoast()วิธีการ

ตัวอย่าง

<script>
$(document).ready(function(){
  $('.toast').toast('show');
});
</script>

ตัวเลือกขนมปัง

ตัวเลือกสามารถส่งผ่านแอตทริบิวต์ข้อมูลหรือ JavaScript สำหรับแอตทริบิวต์ข้อมูล ให้ผนวกชื่อตัวเลือกต่อท้าย เช่น เดียวdata-กับในdata-animation=""

Name Type Default Description Try it
animation boolean true

Specifies whether to add a CSS fade transition effect when showing and hiding the toast.

  • true - Add a fading effect
  • false - Do not add a fading effect
autohide boolean true Specifies whether to hide the toast by default
delay number 500 Specifies the number of milliseconds it will take to hide the toast once it is shown.

วิธีการปิ้งขนมปัง

ตารางต่อไปนี้แสดงรายการวิธีการปิ้งขนมปังที่ใช้ได้ทั้งหมด

Method Description Try it
.toast(options) Activates the toast with an option. See options above for valid values
.toast("show") Shows the toast
.toast("hide") Hides the toast
.toast("dispose") Hides and destroys the toast

กิจกรรมปิ้งขนมปัง

ตารางต่อไปนี้แสดงรายการกิจกรรมขนมปังปิ้งที่มีอยู่ทั้งหมด

Event Description Try it
show.bs.toast Occurs when the toast is about to be shown
shown.bs.toast Occurs when the toast is fully shown (after CSS transitions have completed)
hide.bs.toast Occurs when the toast is about to be hidden
hidden.bs.toast Occurs when the toast is fully hidden (after CSS transitions have completed)