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

จัดให้รายการลอยไปทางขวาด้วย CSS float


Float รายการเฉพาะตัวไปขวา

ใช้ style="float:right" บน <li> ที่ต้องการให้อยู่ขวาสุด ในเมนูที่ลอยซ้าย

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    ul { list-style-type: none; margin: 0; padding: 0; }
    li { float: left; }
    li a { display: block; padding: 8px; background-color: orange; }
  </style>
</head>
<body>
  <ul>
    <li><a href="#home">Home</a></li>
    <li><a href="#news">News</a></li>
    <li style="float:right"><a href="#contact">Contact</a></li>
    <li style="float:right"><a href="#about">About</a></li>
  </ul>
</body>
</html>