Creating a triangle using CSS is pretty easy and common practice, but is it possible to create a triangle in a similar way with a transparent background and just a border.
This is what I would like to create:
Given the way triangles are typically made, I dont really know where to start as they rely on pseudo elements and overlapping borders etc. This obviously cannot be done if the border is transparent...
Does anyone have any ideas of how to do this? Is it even possible?
Use transform:
div {
border: 1px solid #000;
border-width: 0 0 2px 2px;
width: 10px;
height: 10px;
line-height: 0;
font-size: 0;
-webkit-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
div:first-child {
margin-bottom: 25px;
-webkit-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
<div></div>
<div></div>
You can use a pseudo-element to insert a character from this list:
Countersink: ⌵ (U+2335)
Latin capital letter v: V (U+0056)
Latin small letter v: v (U+0076)
Mathematical sans-serif capital v: 𝖵 (U+1d5b5)
Mathematical sans-serif small v: 𝗏 (U+1d5cf)
N-ary logical or: ⋁ (U+22c1)
Roman numeral five: Ⅴ (U+2164)
Small roman numeral five: ⅴ (U+2174)
div {
display: inline-block;
background: #000;
color: #fff;
text-transform: uppercase;
font-family: sans-serif;
font-size: 150%;
padding: .75em;
}
div:after {
content: '⌵';
display: block;
text-align: center;
font-size: 125%;
}
<div>Scroll down</div>
Use Font-awesome, chevron-down
.blk {
width: 150px;
height: 60px;
background-color: black;
}
.blk .fa {
color: white;
margin: 40px 50% auto 50%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<div class="blk">
<i class="fa fa-chevron-down"></i>
</div>
A solution with pseudo-elements. Appliable to any kind of element.
.class:before {
content: "";
width: 15px;
height: 3px;
background-color: black;
display: inline-block;
transform: rotate(45deg);
}
.class:after {
content: "";
width: 15px;
height: 3px;
background-color: black;
display: inline-block;
transform: rotate(-45deg);
margin-left: -7px;
}
body{background:#000;color:#fff;font: 16px/1 sans-serif;}
h2{text-align:center;}
.arrowDown{
position:relative;
}
.arrowDown:after{
content: "";
position:absolute;
left: 50%;
bottom: -16px;
width: 16px;
height: 16px;
margin-left: -8px; /* (16/2) */
border-right: 3px solid #fff;
border-bottom: 3px solid #fff;
transform: rotate(45deg);
}
<h2 class="arrowDown">Scroll down</h2>
Another alternative could be to use SVG to create the shape.
.scroll_down {
box-sizing: border-box;
width: 150px;
height: 90px;
background: black;
padding: 5px;
text-align: center;
}
.scroll_down p {
font-family: sans-serif;
color: white;
}
<div class="scroll_down">
<p>Scroll Down</p>
<svg width="20px" height="10px" viewBox="0 0 20 10">
<path fill="none" stroke-width="2" stroke="white" d="M1,1 L10,9 L19,1"></path>
</svg>
</div>
It's well supported and relatively easy to use.
Related
I have a label "Show more", that display hidden content. I want all child element of this label to be underline including the arrow. The problem is that only the text has text-decoration and not the arrow. How can I solve this issue in order that also arrow will be in the same underline text.
Thanks
#arrow_create {
border: solid black;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 2px;
}
.icos-angle-up {
margin-left: 3px !important;
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
.icos-angle-down {
margin: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
.icos-angle-up {
visibility: hidden;
}
#read_more_checkbox:checked+label[for="read_more_checkbox"]>.icos-angle-up {
visibility: visible;
}
#read_more_checkbox:checked+label[for="read_more_checkbox"]>.icos-angle-down {
display: none;
}
.read_more_txt {
display: none;
}
#read_more_checkbox {
display: none;
}
#read_more_checkbox:checked~.read_more_txt {
display: block;
margin-top: 10px;
}
.read_more_label {
margin-left: 5px !important;
font-weight: bold;
text-transform: uppercase;
}
#read_more_checkbox~.read_more_label:before {
content: attr(read_more);
text-decoration: underline;
text-underline-offset: 4px;
text-decoration-thickness: 1px;
cursor: pointer;
width: 110px;
}
#read_more_checkbox:checked~.read_more_label::before {
text-decoration: underline;
text-underline-offset: 4px;
text-decoration-thickness: 1px;
content: attr(read_less);
cursor: pointer;
}
<label for="read_more_checkbox" class="read_more_label" read_more="Show more" read_less="Show less">
<span id="arrow_create" class="icos-angle-down"></span>
<span id="arrow_create" class="icos-angle-up"></span>
</label>
So instead of using text-decoration (which only applies to text) you can either use border-bottom or to keep it more complicated there is also the possibility of using a css pseudo class.
Using border bottom
.read_more_label {
border-bottom: 1px solid black;
}
#arrow_create {
border: solid black;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 2px;
}
.icos-angle-down {
margin: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<label class="read_more_label">
Show more
<span id="arrow_create" class="icos-angle-down"></span>
</label>
Using css pseudo classes
The benefit of using pseudo classes would be that you also have the chance to design it more and you can even add some litte animations (as I did in the example)
.read_more_label {
position: relative;
}
.read_more_label::after {
content: '';
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
height: 1px;
background-color: black;
opacity: 0;
transition: all 0.2s;
}
.read_more_label:hover::after {
opacity: 1;
}
#arrow_create {
border: solid black;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 2px;
}
.icos-angle-down {
margin: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<p>HOVER IT: </p>
<label class="read_more_label">
Show more
<span id="arrow_create" class="icos-angle-down"></span>
</label>
If shape arrow doesn't matter.
span {
text-decoration: underline;
}
<html>
<body>
<span>SHOW MORE ∨</span>
</body>
</html>
You can use also other HTML Special Characters
Another way
span {
border-bottom: 1px solid black;
}
span::after {
content: "";
border: solid black;
border-width: 0 2px 2px 0;
display: inline-block;
padding: 2px;
margin: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<html>
<body>
<span>SHOW MORE</span>
</body>
</html>
You can use hr tag to draw a line under any thing and then you can add css on hr according to your need.for example if you want to change color of that line you can simply add css on hr tag and change color.
I want to resize the image in an :after element but nothing seems to work, I finally managed to resize it and style it the way I want it using the display:flex but it only works on FireFox. Also whenever I try to put the image in a background or background-image it doesn't display the image at all, no idea what's wrong here.
Here you can see what the website https://tradeideasfx.com/2021/05/16/btc-usd-trade-idea/ it's the "long/short" button at the top of the post. If you view the website on FireFox the buttons look exactly as they should be, but on any other wbsite its all over the place. I appreciate any help in advance.
.post-tags {
float: left;
font-weight: bold;
list-style: none;
padding: 0;
margin: 0;
}
.post-tags>.Long {
color: #FFF;
background-color: #03cd08;
padding: 1px 10px 2px 10px;
border-radius: 10px;
display: inline-block;
}
.post-tags>.Short {
color: #FFF;
background-color: #fc0000;
padding: 1px 10px 2px 10px;
border-radius: 10px;
display: inline-block;
}
.post-tags>.Short:after {
content: url(https://tradeideasfx.com/wp-content/uploads/2021/07/arrow-icon.png);
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
display: inline-flex;
height: 25px;
width: 20px;
padding: 5px;
margin-top: -2px;
}
.post-tags>.Long:after {
content: url(https://tradeideasfx.com/wp-content/uploads/2021/07/arrow-icon.png);
display: inline-flex;
height: 25px;
width: 20px;
padding: 5px;
margin-top: -2px;
}
<span class="post-tags">
<a rel="tag" href="" class="Long">Long</a>
<a rel="tag" href="" class="Short">Short</a> </span>
I m trying to make vertical float button for my website but this is what I m getting. Text is outside box
CSS
#feedback {
height: 104px;
width: 104px;
position: fixed;
top: 40%;
z-index: 999;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
#feedback a {
display: block;
background: #f00;
height: 15px;
width: 70px;
padding: 8px 16px;
color: #fff;
font-family: Arial, sans-serif;
font-size: 17px;
font-weight: bold;
text-decoration: none;
border-bottom: solid 1px #333;
border-left: solid 1px #333;
border-right: solid 1px #fff;
}
#feedback a:hover {
background: #06c;
}
HTML
<div id="feedback">
Test
</div>
The height: 15px is what that causes this issue for you. Everything is fine otherwise. Remove the height from #feedback a and it will be alright.
#feedback a {
display: block;
background: #f00;
height: 15px; /* Remove this... */
Height of an element is generally set by the content and the line-height. If you try to manually set, it goes out of context with the contents. That's what just happened now.
Ok, so everyone knows you can make a triangle using this:
#triangle {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
}
And that produces a solid, filled in triangle. But how would you make a hollow-type arrow-like triangle, like this?
You can use the before or after pseudo-element and apply some CSS to it. There are various ways. You can add both before and after, and rotate and position each of them to form one of the bars. An easier solution is adding two borders to just the before element and rotate it using transform: rotate.
Scroll down for a different solution that uses an actual element instead of the pseuso elements
In this case, I've added the arrows as bullets in a list and used em sizes to make them size properly with the font of the list.
ul {
list-style: none;
}
ul.big {
list-style: none;
font-size: 300%
}
li::before {
position: relative;
/* top: 3pt; Uncomment this to lower the icons as requested in comments*/
content: "";
display: inline-block;
/* By using an em scale, the arrows will size with the font */
width: 0.4em;
height: 0.4em;
border-right: 0.2em solid black;
border-top: 0.2em solid black;
transform: rotate(45deg);
margin-right: 0.5em;
}
/* Change color */
li:hover {
color: red; /* For the text */
}
li:hover::before {
border-color: red; /* For the arrow (which is a border) */
}
<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
<ul class="big">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
Of course you don't need to use before or after, you can apply the same trick to a normal element as well. For the list above it is convenient, because you don't need additional markup. But sometimes you may want (or need) the markup anyway. You can use a div or span for that, and I've even seen people even recycle the i element for 'icons'. So that markup could look like below. Whether using <i> for this is right is debatable, but you can use span for this as well to be on the safe side.
/* Default icon formatting */
i {
display: inline-block;
font-style: normal;
position: relative;
}
/* Additional formatting for arrow icon */
i.arrow {
/* top: 2pt; Uncomment this to lower the icons as requested in comments*/
width: 0.4em;
height: 0.4em;
border-right: 0.2em solid black;
border-top: 0.2em solid black;
transform: rotate(45deg);
}
And so you can have an <i class="arrow" title="arrow icon"></i> in your text.
This arrow is <i class="arrow" title="arrow icon"></i> used to be deliberately lowered slightly on request.
I removed that for the general public <i class="arrow" title="arrow icon"></i> but you can uncomment the line with 'top' <i class="arrow" title="arrow icon"></i> to restore that effect.
If you seek more inspiration, make sure to check out this awesome library of pure CSS icons by Nicolas Gallagher. :)
This can be solved much easier than the other suggestions.
Simply draw a square and apply a border property to just 2 joining sides.
Then rotate the square according to the direction you want the arrow to point, for exaple: transform: rotate(<your degree here>)
.triangle {
border-right: 10px solid;
border-bottom: 10px solid;
height: 30px;
width: 30px;
transform: rotate(-45deg);
}
<div class="triangle"></div>
Responsive Chevrons / arrows
they resize automatically with your text and are colored the same color. Plug and play :)
jsBin demo playground
body{
font-size: 25px; /* Change font and see the magic! */
color: #f07; /* Change color and see the magic! */
}
/* RESPONSIVE ARROWS */
[class^=arr-]{
border: solid currentColor;
border-width: 0 .2em .2em 0;
display: inline-block;
padding: .20em;
}
.arr-right {transform:rotate(-45deg);}
.arr-left {transform:rotate(135deg);}
.arr-up {transform:rotate(-135deg);}
.arr-down {transform:rotate(45deg);}
This is <i class="arr-right"></i> .arr-right<br>
This is <i class="arr-left"></i> .arr-left<br>
This is <i class="arr-up"></i> .arr-up<br>
This is <i class="arr-down"></i> .arr-down
Here's a different approach:
1) Use the multiplication character: × ×
2) Hide half of it with overflow:hidden
3) Then add a triangle as a pseudo element for the tip.
The advantage here is that no transforms are necessary. (It will work in IE8+)
FIDDLE
.arrow {
position: relative;
}
.arrow:before {
content: '×';
display: inline-block;
position: absolute;
font-size: 240px;
font-weight: bold;
font-family: verdana;
width: 103px;
height: 151px;
overflow: hidden;
line-height: 117px;
}
.arrow:after {
content: '';
display: inline-block;
position: absolute;
left: 101px;
top: 51px;
width: 0;
height: 0;
border-style: solid;
border-width: 25px 0 25px 24px;
border-color: transparent transparent transparent black;
}
<div class="arrow"></div>
Just use before and after Pseudo-elements - CSS
*{box-sizing: border-box; padding: 0; margin: 0}
:root{background: white; transition: background .3s ease-in-out}
:root:hover{background: red }
div{
margin: 20px auto;
width: 150px;
height: 150px;
position:relative
}
div:before, div:after{
content: '';
position: absolute;
width: 75px;
height: 20px;
background: black;
left: 40px
}
div:before{
top: 45px;
transform: rotateZ(45deg)
}
div:after{
bottom: 45px;
transform: rotateZ(-45deg)
}
<div/>
An other approach using borders and no CSS3 properties :
div, div:after{
border-width: 80px 0 80px 80px;
border-color: transparent transparent transparent #000;
border-style:solid;
position:relative;
}
div:after{
content:'';
position:absolute;
left:-115px; top:-80px;
border-left-color:#fff;
}
<div></div>
> itself is very wonderful arrow! Just prepend a div with it and style it.
div{
font-size:50px;
}
div::before{
content:">";
font: 50px 'Consolas';
font-weight:900;
}
<div class="arrowed">Hatz!</div>
Left Right Arrow with hover effect using Roko C. Buljan box-shadow trick
.arr {
display: inline-block;
padding: 1.2em;
box-shadow: 8px 8px 0 2px #777 inset;
}
.arr.left {
transform: rotate(-45deg);
}
.arr.right {
transform: rotate(135deg);
}
.arr:hover {
box-shadow: 8px 8px 0 2px #000 inset
}
<div class="arr left"></div>
<div class="arr right"></div>
I needed to change an input to an arrow in my project. Below is final work.
#in_submit {
background-color: white;
border-left: #B4C8E9;
border-top: #B4C8E9;
border-right: 3px solid black;
border-bottom: 3px solid black;
width: 15px;
height: 15px;
transform: rotate(-45deg);
margin-top: 4px;
margin-left: 4px;
position: absolute;
cursor: pointer;
}
<input id="in_submit" type="button" class="convert_btn">
Here Fiddle
.arrow {
display : inline-block;
font-size: 10px; /* adjust size */
line-height: 1em; /* adjust vertical positioning */
border: 3px solid #000000;
border-left: transparent;
border-bottom: transparent;
width: 1em; /* use font-size to change overall size */
height: 1em; /* use font-size to change overall size */
}
.arrow:before {
content: "\00a0"; /* needed to hook line-height to "something" */
}
.arrow.left {
margin-left: 0.5em;
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
-o-transform: rotate(225deg);
-ms-transform: rotate(225deg);
transform: rotate(225deg);
}
.arrow.right {
margin-right: 0.5em;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.arrow.top {
line-height: 0.5em; /* use this to adjust vertical positioning */
margin-left: 0.5em;
margin-right: 0.5em;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.arrow.bottom {
line-height: 2em;
/* use this to adjust vertical positioning */
margin-left: 0.5em;
margin-right: 0.5em;
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-o-transform: rotate(135deg);
-ms-transform: rotate(135deg);
transform: rotate(135deg);
}
<div>
here are some arrows
<div class='arrow left'></div> space
<div class='arrow right'></div> space
<div class='arrow top'></div> space
<div class='arrow bottom'></div> space with proper spacing?
</div>
Similar to Roko C, but a little more control over size and placement.
Ok, so everyone knows you can make a triangle using this:
#triangle {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
}
And that produces a solid, filled in triangle. But how would you make a hollow-type arrow-like triangle, like this?
You can use the before or after pseudo-element and apply some CSS to it. There are various ways. You can add both before and after, and rotate and position each of them to form one of the bars. An easier solution is adding two borders to just the before element and rotate it using transform: rotate.
Scroll down for a different solution that uses an actual element instead of the pseuso elements
In this case, I've added the arrows as bullets in a list and used em sizes to make them size properly with the font of the list.
ul {
list-style: none;
}
ul.big {
list-style: none;
font-size: 300%
}
li::before {
position: relative;
/* top: 3pt; Uncomment this to lower the icons as requested in comments*/
content: "";
display: inline-block;
/* By using an em scale, the arrows will size with the font */
width: 0.4em;
height: 0.4em;
border-right: 0.2em solid black;
border-top: 0.2em solid black;
transform: rotate(45deg);
margin-right: 0.5em;
}
/* Change color */
li:hover {
color: red; /* For the text */
}
li:hover::before {
border-color: red; /* For the arrow (which is a border) */
}
<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
<ul class="big">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
Of course you don't need to use before or after, you can apply the same trick to a normal element as well. For the list above it is convenient, because you don't need additional markup. But sometimes you may want (or need) the markup anyway. You can use a div or span for that, and I've even seen people even recycle the i element for 'icons'. So that markup could look like below. Whether using <i> for this is right is debatable, but you can use span for this as well to be on the safe side.
/* Default icon formatting */
i {
display: inline-block;
font-style: normal;
position: relative;
}
/* Additional formatting for arrow icon */
i.arrow {
/* top: 2pt; Uncomment this to lower the icons as requested in comments*/
width: 0.4em;
height: 0.4em;
border-right: 0.2em solid black;
border-top: 0.2em solid black;
transform: rotate(45deg);
}
And so you can have an <i class="arrow" title="arrow icon"></i> in your text.
This arrow is <i class="arrow" title="arrow icon"></i> used to be deliberately lowered slightly on request.
I removed that for the general public <i class="arrow" title="arrow icon"></i> but you can uncomment the line with 'top' <i class="arrow" title="arrow icon"></i> to restore that effect.
If you seek more inspiration, make sure to check out this awesome library of pure CSS icons by Nicolas Gallagher. :)
This can be solved much easier than the other suggestions.
Simply draw a square and apply a border property to just 2 joining sides.
Then rotate the square according to the direction you want the arrow to point, for exaple: transform: rotate(<your degree here>)
.triangle {
border-right: 10px solid;
border-bottom: 10px solid;
height: 30px;
width: 30px;
transform: rotate(-45deg);
}
<div class="triangle"></div>
Responsive Chevrons / arrows
they resize automatically with your text and are colored the same color. Plug and play :)
jsBin demo playground
body{
font-size: 25px; /* Change font and see the magic! */
color: #f07; /* Change color and see the magic! */
}
/* RESPONSIVE ARROWS */
[class^=arr-]{
border: solid currentColor;
border-width: 0 .2em .2em 0;
display: inline-block;
padding: .20em;
}
.arr-right {transform:rotate(-45deg);}
.arr-left {transform:rotate(135deg);}
.arr-up {transform:rotate(-135deg);}
.arr-down {transform:rotate(45deg);}
This is <i class="arr-right"></i> .arr-right<br>
This is <i class="arr-left"></i> .arr-left<br>
This is <i class="arr-up"></i> .arr-up<br>
This is <i class="arr-down"></i> .arr-down
Here's a different approach:
1) Use the multiplication character: × ×
2) Hide half of it with overflow:hidden
3) Then add a triangle as a pseudo element for the tip.
The advantage here is that no transforms are necessary. (It will work in IE8+)
FIDDLE
.arrow {
position: relative;
}
.arrow:before {
content: '×';
display: inline-block;
position: absolute;
font-size: 240px;
font-weight: bold;
font-family: verdana;
width: 103px;
height: 151px;
overflow: hidden;
line-height: 117px;
}
.arrow:after {
content: '';
display: inline-block;
position: absolute;
left: 101px;
top: 51px;
width: 0;
height: 0;
border-style: solid;
border-width: 25px 0 25px 24px;
border-color: transparent transparent transparent black;
}
<div class="arrow"></div>
Just use before and after Pseudo-elements - CSS
*{box-sizing: border-box; padding: 0; margin: 0}
:root{background: white; transition: background .3s ease-in-out}
:root:hover{background: red }
div{
margin: 20px auto;
width: 150px;
height: 150px;
position:relative
}
div:before, div:after{
content: '';
position: absolute;
width: 75px;
height: 20px;
background: black;
left: 40px
}
div:before{
top: 45px;
transform: rotateZ(45deg)
}
div:after{
bottom: 45px;
transform: rotateZ(-45deg)
}
<div/>
An other approach using borders and no CSS3 properties :
div, div:after{
border-width: 80px 0 80px 80px;
border-color: transparent transparent transparent #000;
border-style:solid;
position:relative;
}
div:after{
content:'';
position:absolute;
left:-115px; top:-80px;
border-left-color:#fff;
}
<div></div>
> itself is very wonderful arrow! Just prepend a div with it and style it.
div{
font-size:50px;
}
div::before{
content:">";
font: 50px 'Consolas';
font-weight:900;
}
<div class="arrowed">Hatz!</div>
Left Right Arrow with hover effect using Roko C. Buljan box-shadow trick
.arr {
display: inline-block;
padding: 1.2em;
box-shadow: 8px 8px 0 2px #777 inset;
}
.arr.left {
transform: rotate(-45deg);
}
.arr.right {
transform: rotate(135deg);
}
.arr:hover {
box-shadow: 8px 8px 0 2px #000 inset
}
<div class="arr left"></div>
<div class="arr right"></div>
I needed to change an input to an arrow in my project. Below is final work.
#in_submit {
background-color: white;
border-left: #B4C8E9;
border-top: #B4C8E9;
border-right: 3px solid black;
border-bottom: 3px solid black;
width: 15px;
height: 15px;
transform: rotate(-45deg);
margin-top: 4px;
margin-left: 4px;
position: absolute;
cursor: pointer;
}
<input id="in_submit" type="button" class="convert_btn">
Here Fiddle
.arrow {
display : inline-block;
font-size: 10px; /* adjust size */
line-height: 1em; /* adjust vertical positioning */
border: 3px solid #000000;
border-left: transparent;
border-bottom: transparent;
width: 1em; /* use font-size to change overall size */
height: 1em; /* use font-size to change overall size */
}
.arrow:before {
content: "\00a0"; /* needed to hook line-height to "something" */
}
.arrow.left {
margin-left: 0.5em;
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
-o-transform: rotate(225deg);
-ms-transform: rotate(225deg);
transform: rotate(225deg);
}
.arrow.right {
margin-right: 0.5em;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.arrow.top {
line-height: 0.5em; /* use this to adjust vertical positioning */
margin-left: 0.5em;
margin-right: 0.5em;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.arrow.bottom {
line-height: 2em;
/* use this to adjust vertical positioning */
margin-left: 0.5em;
margin-right: 0.5em;
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-o-transform: rotate(135deg);
-ms-transform: rotate(135deg);
transform: rotate(135deg);
}
<div>
here are some arrows
<div class='arrow left'></div> space
<div class='arrow right'></div> space
<div class='arrow top'></div> space
<div class='arrow bottom'></div> space with proper spacing?
</div>
Similar to Roko C, but a little more control over size and placement.