0

Народ подскажите как будет выглядить код, как сделать прямоугольный треугольник понимаю, а оводку вокруг прямоугольного не выходит

<div class="box arrow-top">
  This is a box with some content and an arrow at the top.
</div>
.box {
  width: 150px;
  height: 75px;
  background-color: grey;
  color: #fff;
  padding: 20px;
  position: relative;
  margin: 40px;
  float: left;
}


.box.arrow-top:after {
  content: " ";
  position: absolute;
  right: 30px;
  top: -15px;
  border-top: none;
  border-right: 15px solid transparent;
  border-bottom: 15px solid grey;
}

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

0

1 ответ 1

2

Можно сделать один черный треугольник, чуть побольше. И накрыть его мелким красным:

.dialog {
  position: relative;
  width: 300px;
  height: 100px;
  margin: 40px;
  background-color: #c22;
  border: 5px solid black;
  
  padding: 5px;
  color: white;
}

.dialog::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  
  border: 28px solid transparent;
  border-right-color: #000;
  transform: rotate(-45deg);
  
  top: -28px;
  left: 7px;
}

.dialog::after {
  content: "";
  position: absolute;  
  width: 0;
  height: 0;
  
  border: 20px solid transparent;
  border-right-color: #c22;
  transform: rotate(-45deg);
  
  top: -20px;
  left: 20px;
}
<div class="dialog">
  This is a box with some content and an arrow at the top.
</div>

1
  • Спасибо за готовый код! Разобрался как это делается
    – Иван
    10 июн 2020 в 11:09

Ваш ответ

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

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.