CSS Как добавить границу в треугольник?
В моем случае у меня есть что-то следующее:
http://jsfiddle.net/pyx3zx25/12/
и вопрос в том, как я могу добавить границу также в треугольник.
Мой css:
.slide{
position: relative;
padding: 15px;
}
.arrow {
max-width: 300px;
background-color: #E01616;
position: absolute;
top: -10px;
left: -10px;
margin: 5px 0 0 5px;
border: 3px solid black;
}
.arrow:after {
left: 100%;
bottom: 0px;
content: "";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-width: 15px;
border-bottom: 30px solid #E01616;
border-right: 30px solid transparent;
}
+2
3 ответа
Используйте псевдоэлемент :before
псевдоэлементом, чтобы создать треугольник с похожими углами с несколькими настройками, чтобы он выглядел как ваш :after
элемента имеет границу:
.slide{
position: relative;
padding: 15px;
}
.arrow {
max-width: 300px;
background-color: #E01616;
position: absolute;
top: -10px;
left: -10px;
margin: 5px 0 0 5px;
border: 3px solid black;
}
.arrow:after {
left: 100%;
bottom: 0px;
content: "";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-width: 15px;
border-bottom: 30px solid #E01616;
border-right: 30px solid transparent;
}
.arrow:before {
left: 100%;
bottom: -3px;
content: "";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-width: 15px;
border-bottom: 37px solid #000;
border-right: 37px solid transparent;
}
<div class="slide">
<div class="arrow">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer scelerisque ex eget ultricies blandit.</p>
</div>
</div>
+4
Вы не можете использовать границу, потому что используете ее уже.
Попробуй. UPDTATE
.arrow:before{
border-bottom: 40px solid #000;
border-right: 37px solid transparent;
border-width: 0 37px 40px 0;
bottom: 0;
content: "";
left: 100%;
position: absolute;
top: 55px;
}
0
jsfiddle - jsfiddle
HTML
<div class="slide">
<div class="arrow">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer scelerisque ex eget ultricies blandit.</p>
</div>
</div>
CSS
.slide{
position: relative;
padding: 15px;
}
.arrow {
max-width: 300px;
background-color: #E01616;
position: absolute;
top: -10px;
left: -10px;
margin: 5px 0 0 5px;
border: 3px solid black;
}
.arrow:after {
left: 100%;
bottom: 0px;
content: "";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-width: 15px;
border-bottom: 30px solid #E01616;
border-right: 30px solid transparent;
box-shadow: 0px 3px 0px 0px #000;
}
.arrow:before{
content: "";
right: -30px;
bottom: 0px;
height: 3px;
width: 30px;
position: absolute;
background: #000;
pointer-events: none;
transform: rotate(45deg) translate(-8px,-11px) scale(1.45);
}
0
Посмотрите другие вопросы по меткам html css css3 css-shapes или Задайте вопрос