text-stroke касиети

text-stroke касиети текст символдорунун контурдун түсүн жана калыңдыгын же анын контурун коёт. Касиетке маани катары контурдун калыңдыгын жана боштук менен контурдун түсүн бериш керек.

Синтаксис

cssселектор {
  text-stroke: контурдун калыңдыгы жана анын түсү;
}

Негизги мисал

Жөнөкөй текст контуру:

html<div class="stroked-text">
  Lorem ipsum dolor sit amet
</div>
css.stroked-text {
  font-size: 48px;
  font-weight: bold;
  -webkit-text-stroke: 2px red;
  text-stroke: 2px red;
}

Результат:

Контур гана

Эми тексттин түсүн фондун түсү менен дал келтирип көрөлү (биздин учурда ак). Натыйжада контур гана калат:

html<div class="stroked-text">
  Lorem ipsum dolor sit amet
</div>
css.stroked-text {
  font-size: 48px;
  font-weight: bold;
  color: white;
  -webkit-text-stroke: 2px black;
  text-stroke: 2px black;
}

Результат:

Градиенттүү контур

background-clip касиетинин жардамы менен градиенттүү контур жасайлы:

html<div class="gradient-stroke">
  Lorem ipsum dolor sit amet
</div>
css.gradient-stroke {
  font-size: 42px;
  font-weight: bold;
  background: linear-gradient(to right, #ff8a00, #e52e71);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px #333;
  text-stroke: 1px #333;
}

Результат:

Көп контур

text-shadow касиетинин жардамы менен кош контур эффектиси:

html<div class="double-stroke">
  Lorem ipsum dolor sit amet
</div>
css.double-stroke {
  font-size: 40px;
  color: white;
  -webkit-text-stroke: 3px #000;
  text-stroke: 3px #000;
  text-shadow: 
    0 0 5px #000,
    0 0 10px #000;
}

Результат:

Анимацияланган контур

Контурдун өзгөрүү анимациясын кошолу:

html<div class="animated-stroke">
  Lorem ipsum dolor sit amet
</div>
css.animated-stroke {
  font-size: 38px;
  color: white;
  -webkit-text-stroke: 1px #ff0000;
  text-stroke: 1px #ff0000;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { -webkit-text-stroke: 1px #ff0000; text-stroke: 1px #ff0000; }
  50% { -webkit-text-stroke: 3px #ff0000; text-stroke: 3px #ff0000; }
  100% { -webkit-text-stroke: 1px #ff0000; text-stroke: 1px #ff0000; }
}

Результат:

Дагы караңыз

  • text-fill-color касиети,
    текст символдорунун толтуруу түсүн коёт
  • text-stroke-color касиети,
    тексттин контур түсүн коёт
  • text-stroke-width касиети,
    тексттин контур калыңдыгын коёт