คุณสมบัติการเติมใน CSS ช่วยให้คุณตั้งค่าการเติมสำหรับช่องว่างบน, การเติม-ขวา, การเติม-ด้านล่าง, การเติม-ซ้าย เป็นสมบัติชวเลข
เรามาดูตัวอย่างกันก่อน −
ตัวอย่างเช่น padding:10px 5px 7px 10px;
ที่นี่
top padding is 10px right padding is 5px bottom padding is 7px left padding is 10px
ตัวอย่าง
ตัวอย่างต่อไปนี้แสดงให้เห็นถึงคุณสมบัติการเติม CSS -
<!DOCTYPE html>
<html>
<head>
<style>
div {
height: 150px;
width: 300px;
padding: 5% 10% 20% 5%;
background-image: url("https://www.tutorialspoint.com/images/home_tensor_flow.png");
text-align: center;
font-weight: bold;
font-size: 1.2em;
box-sizing: border-box;
}
div > div {
border-radius: 80px;
padding: 2em 2em;
box-shadow: 0 0 4px 0.8px black;
}
</style>
</head>
<body>
<div>Learn TensorFlow
<div>TensorFlow is an open source machine learning framework for all developers.</div>
</div>
</body>
</html> ผลลัพธ์
ซึ่งจะได้ผลลัพธ์ดังต่อไปนี้

ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
div {
height: 150px;
width: 100px;
padding: 5% 1%;
background-color: papayawhip;
border-radius: 5%;
box-sizing: border-box;
}
div > div {
width: 50px;
height: 50px;
border-radius: 50%;
padding: 2em;
box-shadow: 0 0 9px 1px black;
}
span {
padding: 10px;
}
</style>
</head>
<body>
<div>
<div></div>
<span><i>button</i></span>
</div>
</body>
</html> ผลลัพธ์
ให้ผลลัพธ์ดังต่อไปนี้ -
