CSS Shorthand ທີ່​ຈະ​ເຮັດໃຫ້​ເຈົ້າ​ຂຽນ​ CSS ງ່າຍ​ ໆ​ ໃນ​ 1 ບັນ​ທັດ​

CSS ເປັນ​ພາສາ​ທີ່​ຂຽນ​ເພື່ອ​ໃຫ້​ເວັບ​ໄຊ​ຕ໌​ສາມາດ​ສະແດງ​ອົງ​​ປະກອບ​ຕ່າງ​ ໆ​ ໄດ້​ຕາມ​ຕ້ອງ​ການ​ ເຊັ່ນ​ ສີ​ ຟອນ​ ຄວາມ​ສູງ​ ຄວາມ​ກວ້າງ​ ໄລຍະ​ຫ່າງ​ຂອງ​ຂອບ​ ແລະ ​ອື່ນ​ໆ​ ອີກ​ຫລວງ​ຫລາຍ​ ຊຶ່ງ​ໃນ​ບົດ​ຄວາມ​ນີ້​ຈະ​ມາ​ແຈກ​ເທັກນິກ​ດີ​ໆ​ ທີ່​ເຮັດໃຫ້​ເພື່ອນ​ໆ​ ສາມາດ​ຂຽນ​ CSS ໄດ້​ງ່າຍ​ໃນ​ 1 ບັນ​ທັດ​

ເປັນຫຍັງ​ຕ້ອງ​ຂຽນ​ CSS Shorthand ?

  • ຊ່ວຍ​ປັບ​ປຸງ​ໂຄ້ດ​ ສາມາດ​ອ່ານ​ ແລະ​ ເຮັດ​ຄວາມ​ເຂົ້າໃຈ​ໂຄ້ດ​ໄດ້​ງ່າຍ​ຫລາຍ​ຢິ່ງ​ຂຶ້ນ​
  • ຊ່ວຍ​ປັບ​ປຸງ​ປຣະ​ສິດ​ທິ​ພາບ​ຂອງ​ການ​ໂຫຼດ​ໜ້າ​ເວັບ​

Background Shorthand
ຊ່ວຍ​ໃຫ້​ເຮົາ​ສາມາດ​ກຳນົດ​ຄຸນສົມບັດ​ຕ່າງ​ ໆ​ ເທິງ​ພື້ນ​ຫຼັງ​ໄດ້​ຕາມ​ຕ້ອງ​ການ​ ເຊັ່ນ​ ສີ​ ຂະໜາດ​ ຮູບ​ພາບ​ ຕຳແໜ່ງ​ 

🔹 Old

.container {
background-color: #000;
background-image: url(images/bg.gif);
background-repeat: no-repeat;
background-position: left top;
}

🔸 Shorthand

.container{
background: #000 url(images/bg.gif) no-repeat left top;
}
 Border Shorthand

🔹 Old 

.container{
   border-width: 1px;
   border-style: solid;
   border-color: #000;
}

🔸 Shorthand

.container{
border: 1px solid #000;
}

Font Shorthand

🔹 Old

.container{
font-style:italic;
font-weight:bold;
font-size:.8em;
line-height:1.5;
font-family:Arial, Helvetica, sans-serif
}

🔸 Shorthand

.container{
   font: italic bold .8em/1.5 Arial, Helvetica, sans-serif;
}

Inset Shorthand

🔹 Old

 .container{
top: 10px;
right: 4px;
bottom: 4px;
left: 10px;
}

🔸 Shorthand

.container{
/* top | right | bottom | left */
inset: 10px 4px 4px 10px;
}

Padding Shorthand

🔹 Old

.container{
padding-top: 10px;
padding-right: 5px;
padding-bottom: 10px;
padding-left: 5px;
}

🔸 Shorthand

.container{
   /* top | right | bottom | left */
   padding: 10px 5px 10px 5px;
}
 
Margin Shorthand

🔹 Old

.container{
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
margin-left: 10px;
}

🔸 Shorthand

.container{
/* top | right | bottom | left */
margin: 10px 10px 10px 10px;
}

ແລະ ​ທັງ​ໝົດ​ນີ້​ຄື​ CSS Shorthand ທີ່​ເຮົາ​ນຳ​ມາ​ຝາກ​ເພື່ອນ​ ໆ​ ລອງ​ໄປ​ປັບ​ໃຊ້​ກັບ​ໂປຣ​ເຈັກ​​ກັນ​ເບິ່ງ​ນະ​ ແລະ​ ຫາກ​ບົດ​ຄວາມ​ນີ້​ຜິດ​ພາດ​ປະການ​ໃດ​ ກໍ​ຂໍ​ອ​ະໄພ​ມາ​ ນະ​ ທີ່​ນີ້​ດ້ວຍ​

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top