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

จะสร้างข้อความแจ้งเตือนด้วย CSS ได้อย่างไร?


ในการสร้างข้อความแจ้งเตือนด้วย CSS โค้ดจะเป็นดังนี้ -

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   body{
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
   }
   .alertMessage {
      padding: 20px;
      background-color: #f44336;
      color: white;
      font-size: 20px;
   }
   .close{
      margin-left: 15px;
      color: white;
      font-weight: bold;
      float: right;
      font-size: 22px;
      line-height: 20px;
      cursor: pointer;
      transition: 0.3s;
   }
   .close:hover {
      color: black;
   }
</style>
</head>
<body>
<h1>Alert Message Example</h1>
<div class="alertMessage">
<span class="close" onclick="this.parentElement.style.display='none';">×</span>
<strong>This cannot be revered!</strong> You account will be deleted.
</div>
</body>
</html>

ผลลัพธ์

รหัสข้างต้นจะสร้างผลลัพธ์ต่อไปนี้ -

จะสร้างข้อความแจ้งเตือนด้วย CSS ได้อย่างไร?