เราใช้คุณสมบัติลักษณะที่ปรากฏเพื่อจัดรูปแบบองค์ประกอบตามสไตล์ดั้งเดิมของแพลตฟอร์มของระบบปฏิบัติการของผู้ใช้
ไวยากรณ์
ไวยากรณ์ของคุณสมบัติลักษณะที่ปรากฏ CSS มีดังต่อไปนี้ -
Selector {
appearance: /*value*/;
-webkit-appearance: /*value*/; /*for Safari and Chrome */
-moz-appearance: /*value*/; /*for Firefox */
} ตัวอย่าง
ตัวอย่างต่อไปนี้แสดงให้เห็นถึงคุณสมบัติลักษณะที่ปรากฏของ CSS
<!DOCTYPE html>
<html>
<style>
input[type=radio] {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
padding: 10px;
background-color: orange;
border-radius:50%;
}
input[type=radio]:checked {
background-color: magenta;
}
input[type=radio]:hover {
cursor: pointer;
}
</style>
<body>
Custom radio button example<br/>
<form>
<label for="r1">r1</label>
<input type="radio" id="r1" name="btn" value="v1">
<input type="radio" id="r2" name="btn" value="v2">
<label for="r2">r2</label>
</form>
</body>
</html> สิ่งนี้ให้ผลลัพธ์ต่อไปนี้

ตัวอย่าง
<!DOCTYPE html>
<html>
<style>
label {
display: flex;
align-items: top;
}
label input {
margin: 0px 10px 0px 10px;
}
input[type=checkbox] {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
border: 3px ridge currentcolor;
border-radius: 60px;
box-sizing: content-box;
color: lightblue;
height: 60px;
padding: 2px 2px 2px 2px;
transition-duration: 280ms;
transition-property: border-color, color;
transition-timing-function: ease;
width: 20px;
}
input[type=checkbox]:checked {
color: lightgreen;
}
input[type=checkbox]::after {
background-color: currentcolor;
border-radius: 10px 10px 10px 10px;
content: "";
display: block;
height: 20px;
transform: translateY(0px);
transition: transform 300ms ease-in;
width: 20px ;
}
input[type=checkbox]:checked::after {
transform: translateY(40px);
}
</style>
<body>
<p>
Custom radio button example
<label for="crb">
Blue
<input id="crb" type="checkbox"/>
<br/><br/><br/>Green
</label>
</p>
</body>
</html> สิ่งนี้ให้ผลลัพธ์ต่อไปนี้

