I'm working on a 'arrow'-div. It currently looks like this:
the div contains two other divs(two lines). And I want that the background is nearly wrapped around the lines. But the height of the yellow-background is a lot smaller than the height of the lines. I already tried 'height: auto'. I hope someone could help me out.
#lineAll {
background-color: yellow;
height: auto;
}
#line1 {
height: 2px;
background-color: black;
transform: rotate(35deg);
width: 40px;
}
#line2 {
height: 2px;
background-color: black;
transform: rotate(-35deg);
width: 40px;
margin-top: 20px;
}
<div id="lineAll">
<div id="line1"></div>
<div id="line2"></div>
</div>
edit:
The width is also not the way I want it. It's currently 100%-width of the screen.
The default background color of a div is transparent . So if you do not specify the background-color of a div, it will display that of its parent element.
Put the text in an inline element, such as a <span> . And then apply the background color on the inline element. An inline element is as big as its contents is, so that should do it for you.
Try this:
<div style="background-color : yellow; padding: 15px 0px; width: 40px;">
<div id="lineAll">
<div id="line1"></div>
<div id="line2"></div>
</div>
</div>
<style>
#lineAll {
background-color: yellow;
height: auto;
}
#line1 {
height: 2px;
background-color: black;
transform: rotate(35deg);
width: 40px;
}
#line2 {
height: 2px;
background-color: black;
transform: rotate(-35deg);
width: 40px;
margin-top: 20px;
}
You can do this with one element and :after
pseudo-element. Just create smaller pseudo-element that has border-top
and border-right
and then rotate it for 45deg
.
.element {
width: 50px;
height: 60px;
background: yellow;
position: relative;
}
.element:after {
content: '';
position: absolute;
top: 15px;
border-top: 1px solid black;
border-right: 1px solid black;
height: 30px;
width: 30px;
transform: rotate(45deg);
}
<div class="element"></div>
To create other button just rotate for -135deg
and set right: 0px
.element {
width: 50px;
height: 60px;
background: yellow;
position: relative;
display: inline-block;
margin: 50px;
}
.element:after {
content: '';
position: absolute;
top: 15px;
border-top: 1px solid black;
border-right: 1px solid black;
height: 30px;
width: 30px;
transform: rotate(45deg);
}
.element.right:after {
transform: rotate(-135deg);
right: 0px;
}
<div class="element"></div>
<div class="element right"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With