+ 3

Can I make a triangle out of a square or rectangle using div?

I made a rectangle using div,I want to make it a triangle,is it possible?

18th Oct 2022, 8:40 AM
JƌáșžlÔXℱ
JƌáșžlÔXℱ - avatar
4 RĂ©ponses
+ 2
It's really sort of a hack. If you observe the example: .arrow-up { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 5px solid black; } This looks like an arrow pointing upwards. The size of the div itself is zero. But there is a black border at the bottom. And two transparent borders on both sides. But we can't really draw such borders around something that has 0 width and height, can we? Well, the browser just surrounds the "nothing" with lines, and the cross-over of the transparent and black border, actually represent the slanted side of the triangle. This kind of trick is not really the intended usage of CSS attributes, but it can be fun to draw different shapes from abstract containers such as DIV. :)
18th Oct 2022, 12:28 PM
Tibor Santa
Tibor Santa - avatar
18th Oct 2022, 8:46 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Thank you a lot 😊
18th Oct 2022, 12:32 PM
JƌáșžlÔXℱ
JƌáșžlÔXℱ - avatar
0
I haven't yet reached the border-left and right of CSS but can you explain it in simple terms for me?
18th Oct 2022, 8:51 AM
JƌáșžlÔXℱ
JƌáșžlÔXℱ - avatar