8

Увидел на просторах интернета вот такой эффект для текста на svg, и судя по названию понял что этот эффект называется слешед.

Решил его реализовать на чистом css без вкусного svg

введите сюда описание изображения

и вот что получилось :

html,
body {
  height: 100%;
}

body {
  -webkit-transform: rotate(-5deg);
  -moz-transform: rotate(-5deg);
  -o-transform: rotate(-5deg);
  -ms-transform: rotate(-5deg);
  transform: rotate(-5deg);
}

.lensky {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  text-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
}

.lensky .top,
.lensky .bottom {
  text-align: center;
  font: 62px/100px arial;
  text-transform: uppercase;
  text-align: center;
  overflow: hidden;
  color: #000;
}

.lensky .top:before,
.lensky .bottom:before {
  content: attr(title);
  -webkit-transform: rotate(5deg);
  -moz-transform: rotate(5deg);
  -o-transform: rotate(5deg);
  -ms-transform: rotate(5deg);
  transform: rotate(5deg);
}

.lensky .top {
  position: absolute;
  top: 0;
  left: 5px;
  right: 0;
  bottom: 50%;
}

.lensky .top:before {
  position: absolute;
  bottom: -50px;
  left: 0;
  right: 0;
}

.lensky .bottom {
  position: absolute;
  top: 50%;
  left: 0;
  right: 5px;
  bottom: 0;
}

.lensky .bottom:before {
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
}
<div class="lensky">
  <div class="top" title="lensky"></div>
  <div class="bottom" title="lensky"></div>
</div>

Моё мнение такое,- что выглядит это как-то криворуко,
можно ли как то это улучшить или сделать более красиво ?

6
  • Если честно, не понятно, что именно тебя не утраивает... Код или дизайнерское решение....?
    – Air
    4 апр 2018 в 4:58
  • @Air я думал можно сократить css , как то объеденить или убрать дублирующий слой в html - в общем красивее что ли ... сделать
    – user33274
    4 апр 2018 в 5:00
  • В теге стоит clip-path, почему его и не использовать в псевдоселекторах? И тогда одним тегом будет идти 4 апр 2018 в 5:00
  • на clip-path не получилось у меня ! вот именно этой реализации частично я ожидаю или просто на css но более красивее что ли ,без rotate как то ...
    – user33274
    4 апр 2018 в 5:02
  • clip-path не будет работать в IE EDGE, если тебя это не смущает то могу показать как реализовать с помощью clip-path
    – Air
    4 апр 2018 в 5:11

2 ответа 2

5

С помощью clip-path так:

.gorlachev {
  text-shadow: 3px 3px 3px rgba(0, 0, 0, 0.25);
  font: 62px arial;
  position: relative;
  display:inline-block;
}

.gorlachev:before,
.gorlachev:after {
  content: attr(title);
  clip-path: polygon(0 100%, 0 65%, 110% 45%, 110% 100%);
}

.gorlachev:before {
  clip-path: polygon(0 65%, 0 0, 100% 0, 110% 45%); /* 110 чтобы тень не перекывала */
  position: absolute;
  padding-left: 2%;
}
<div class="gorlachev" title="Gorlachev"></div>

2
4

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  background: #0c0c0c;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lensky {
  height: 150px;
  width: 400px;
  background: transparent;
  overflow: hidden;
  position: relative;
  color: #331;
  text-align: center;
  font-size: 100px;
  font-family: monospace;
  font-weight: 900;
  letter-spacing: 10px;
  text-shadow: 1px 1px 30px #9ff;
}

.lensky:before,
.lensky::after {
  background: transparent;
  position: absolute;
  content: attr(title);
  height: 100%;
  width: 100%;
  top: -1px;
  left: 0;
  line-height: 1.3;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 55%);
}

.lensky::after {
  top: 1px;
  clip-path: polygon(0 55%, 100% 45%, 100% 100%, 0 100%);
  transform: translateX(-3px);
}
<div class="lensky" title="Lensky"></div>

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.