Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

CSS overflow: auto


แสดง scrollbar เมื่อจำเป็น

overflow: auto จะเพิ่ม scrollbar ก็ต่อเมื่อเนื้อหาล้น ไม่เหมือน overflow: scroll ที่แสดงตลอดเวลา

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    div {
      background-color: orange;
      width: 250px;
      height: 45px;
      border: 2px solid blue;
      overflow: auto;
    }
  </style>
</head>
<body>
  <h1>Heading</h1>
  <div>Overflow property used here...</div>
</body>
</html>