- ВКонтакте
- РћРТвЂВВВВВВВВнокласснРСвЂВВВВВВВВРєРСвЂВВВВВВВВ
- РњРѕР№ Р В Р’В Р РЋРЎв„ўР В Р’В Р РЋРІР‚ВВВВВВВВРЎР‚
- Viber
- Skype
- Telegram
Как сделать прямоугольник с хвостиком на css?
Подскажите, пожалуйста, как можно сделать прямоугольник со стрелкой, выходящей из верхнего левого края? Я пробовал через ::before
с полукругом, но не получилось достичь такой формы.
.BigField {
position: relative;
left: 0;
top: 74px;
height: 50px;
width: 624px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
background-color: white;
}
.SmallField {
position: relative;
}
.SmallField form {
display: flex;
flex-direction: column;
gap: 10px;
}
.textarea-wrapper {
position: relative;
}
.textarea-wrapper::before {
content: "";
position: absolute;
width: 10px;
height: 10px;
border: 10px solid transparent;
border-right-color: rgb(255, 0, 0);
border-radius: 50%;
left: 20px;
top: 3px;
}
.SmallField textarea {
position: absolute;
height: 28px;
width: 572px;
top: 8px;
right: 8px;
resize: none;
border-radius: 14px;
outline: none;
border: none;
color: white;
background-color: rgba(0, 0, 0);
padding: 0 11px;
line-height: 28px;
cursor: text;
caret-color: white;
box-sizing: border-box;
}
.SmallField textarea::placeholder {
color: white;
}
<div class="BigField">
<div class="SmallField">
<form>
<div class="textarea-wrapper">
<textarea placeholder="Текст"></textarea>
</div>
</form>
</div>
</div>
Ответы (1 шт):
Автор решения: Qwertiy
→ Ссылка
Для браузеров, поддерживающих скругление outline:
body {
background: repeating-linear-gradient(to right, white, antiquewhite, white 2em);
}
div {
--r: 1.5em;
background: silver;
width: fit-content;
padding: 1em 2em;
border-radius: var(--r);
border-top-left-radius: 0;
margin-left: var(--r);
position: relative;
}
div::before {
content: "";
position: absolute;
inset: 0 100% auto auto;
box-sizing: content-box;
height: var(--r);
aspect-ratio: 1;
border-top-right-radius: 100%;
outline: var(--r) solid silver;
clip-path: inset(0 0 0 1px); /* 1px от полоски-артефакта слева */
animation: tail 1s linear alternate infinite;
}
@keyframes tail {
from { aspect-ratio: 1 / 2; }
to { aspect-ratio: 1; }
}
<div>Привет</div>
<br>
<div>Привет<br>от высокого<br>блока</div>