Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make the right side of a div as an arrow

I have a simple div on a page:

<div>Some Text</div> 

Is it possible, with CSS, to make it finish as an arrow. Something like:

Div with Arrow

UPDATE

This is the result I see with web-tiki proposed solution:

web-tiki proposed solution

See the cuts on the arrow?

Thank You, Miguel

like image 215
Miguel Moura Avatar asked Apr 16 '14 11:04

Miguel Moura


People also ask

How do I Center an arrow in a Div?

Go ahead and see for yourself. Next you'll want to use the margin property to center the arrow on the div. You could also use the margin to give the arrow an offset from the center if that would work better for your design. After that, go ahead and set the height and width properties to zero.

How to create a right arrow in HTML with CSS?

Step 1) Add HTML: Example <p>Right arrow: <i class="arrow right"></i></p> <p>Left arrow: <i class="arrow left"></i></p> <p>Up arrow: <i class="arrow up"></i></p> <p>Down arrow: <i class="arrow down"></i></p> Step 2) Add CSS: Example .arrow { border: solid black;

Why won't my Arrow stay on the bottom border of a Div?

Then you have to set a position value in order for the arrow to stay on that bottom border you set for the div. Without this value being set, your arrow will not show up where you think it will.

Where is the arrow right option positioned on the page?

This is an arrow right option positioned at the top border of the page This arrow animation activates when hovered over. The icon head points towards the top border of the screen. This CSS arrow points to the right with an animation effect that activates when hovered over.


Video Answer


2 Answers


EDIT : If you need the arrow to adapt to the height of the text (considering it can display on several lines) You can use linear-gradient background for the arrow.

FIDDLE


This can make it :

FIDDLE

CSS :

div{     height:40px;     background:red;     color:#fff;     position:relative;     width:200px;     text-align:center;     line-height:40px; } div:after{     content:"";     position:absolute;     height:0;     width:0;     left:100%;     top:0;     border:20px solid transparent;     border-left: 20px solid red; } 
like image 173
web-tiki Avatar answered Oct 02 '22 23:10

web-tiki


Check This

DEMO

HTML

<div class="text">Some Text<span class="arrow"></span> </div> 

CSS

.text {     background-color:#ff0000;     color:#fff;     display:inline-block;     padding-left:4px; } .arrow {     border-style: dashed;     border-color: transparent;     border-width: 0.20em;     display: -moz-inline-box;     display: inline-block;    /* Use font-size to control the size of the arrow. */     font-size: 100px;     height: 0;     line-height: 0;     position: relative;     vertical-align: middle;     width: 0;     background-color:#fff;   /* change background color acc to bg color */      border-left-width: 0.2em;     border-left-style: solid;     border-left-color: #ff0000;     left:0.25em; } 
like image 43
Santy Avatar answered Oct 03 '22 01:10

Santy