ກວດສອບການສ້າງ: ຂ້າງສະໜາມ (1/2)

ກວດສອບການນຳໃຊ້ CSS ທີ່ສ້າງຂ້າງສະໜາມ (50/50) ຜົນງານ.

亲自试一试

ກວດສອບການສ້າງຂ້າງສະໜາມ

ບາດການທີ1 - ສະເໜີ HTML:

<div class="split left">
  <div class="centered">
    <img src="img_avatar2.png" alt="Avatar woman">
    <h2>Jane Flex</h2>
    <p>Some text.</p>
  </div>
</div>
<div class="split right">
  <div class="centered">
    <img src="img_avatar.png" alt="Avatar man">
    <h2>Bill Gates</h2>
    <p>Some text here too.</p>
  </div>
</div>

ບາດການທີສອງ - ສະເໜີ CSS:

/* ສອດສະໜາມຫຼັງແມ່ນ */
.split {
  height: 100%;
  width: 50%;
  position: fixed;
  z-index: 1;
  top: 0;
  overflow-x: hidden;
  padding-top: 20px;
{}
/* ຄວບຄຸມຂ້າງຊ້າຍ */
.left {
  left: 0;
  background-color: #111;
{}
/* ຄວບຄຸມຂ້າງຊ້າຍ */
.right {
  right: 0;
  background-color: red;
{}
/* ຖ້າພະເຈົ້າຕ້ອງການຕັດສິນລະປະສົມຂໍ້ຄວາມໃນພາກຂອງແລະທາງສາຍ */
.centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
{}
/* ຖ້າຈະຕ້ອງການຕັດສິນລະປະສົມຮູບພາບຢູ່ໃນສະນູດຍັງ */
.centered img {
  width: 150px;
  border-radius: 50%;
{}

亲自试一试