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

คุณสมบัติ CSS แปลกใหม่สำหรับฟิลด์ป้อนข้อมูลฟอร์ม (Form Input Fields)

CSS caret-color, pointer-events และ tab-size เป็นคุณสมบัติที่นิยมน้อยกว่าสำหรับฟิลด์ป้อนข้อมูลฟอร์ม caret-color ช่วยระบุสีของเคอร์เซอร์กระพริบ ในขณะที่ pointer-events ช่วยป้องกันไม่ให้ผู้ใช้โต้ตอบกับองค์ประกอบ ส่วน tab-size ตั้งค่าปริมาณช่องว่างที่ใช้โดยแท็บ

ตัวอย่างที่ 1: tab-size และ pointer-events

<!DOCTYPE html> 
<html> 
<head> 
<style> 
body { 
  display: flex; 
  flex-direction: column; 
  background-color: mistyrose; 
} 
p { 
  white-space: pre; 
} 
p:last-of-type { 
  tab-size: 32; 
  -moz-tab-size: 32; 
  pointer-events: none; 
} 
</style> 
</head> 
<body> 
<p> Ut sed felis lobortis, fermentum magna vitae, imperdiet lectus.</p> 
<p> Ut sed felis lobortis, <a href=#>fermentum magna vitae</a>, imperdiet lectus.</p> 
</body> 
</html>

ผลลัพธ์

จะได้ผลลัพธ์ดังนี้:

คุณสมบัติ CSS แปลกใหม่สำหรับฟิลด์ป้อนข้อมูลฟอร์ม (Form Input Fields)

ตัวอย่างที่ 2: caret-color ในฟอร์ม

<!DOCTYPE html> 
<html> 
<head> 
<style> 
form { 
  padding: 2%; 
  margin: 3%; 
  background-color: cadetblue; 
  text-align: center; 
} 
form:focus-within { 
  box-shadow: 0 0 10px rgba(0,0,0,0.6); 
} 
input { 
  caret-color: navy; 
  font-size: 40px; 
  font-weight: large; 
} 
</style> 
</head> 
<body> 
<form> 
<select> 
<option>.</option> 
<option>..</option> 
<option>...</option> 
</select> 
<input type="text" value="glee" /> 
</form> 
</body> 
</html>

ผลลัพธ์

จะได้ผลลัพธ์ดังนี้:

คุณสมบัติ CSS แปลกใหม่สำหรับฟิลด์ป้อนข้อมูลฟอร์ม (Form Input Fields)