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

คุณสมบัติ CSS word-wrap - ตัดคำยาวขึ้นบรรทัดใหม่


คุณสมบัติ word-wrap (ปัจจุบันคือ overflow-wrap) ใช้เพื่อบังคับให้คำที่ยาวเกินไปตัดบรรทัดและขึ้นบรรทัดใหม่

ตัวอย่าง

ตัวอย่างไวยากรณ์:

<!DOCTYPE html>
<html>
  <head>
    <style>
      div {
        width: 200px;
        border: 2px solid #000000;
      }
      div.b {
        word-wrap: break-word;
      }
    </style>
  </head>
  <body>
    <h2>word-wrap: break-word property</h2>
    <div class="b">ThisisdemotextThisisdemotext: thisisaveryveryveryveryveryverylongword. The long word wraps to the next line.</div>
  </body>
</html>

ผลลัพธ์

คุณสมบัติ CSS word-wrap - ตัดคำยาวขึ้นบรรทัดใหม่