I have this image (attached). I am not a designer but I do not want to use the image in my app. I heard you can come very close to an image using css. Can someone help me with this image and turnning into a css equivalent
thanks!
TRIED
<span class="xyz">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<polygon points="0,0 100,0 100,40 0,40 20,20" style="fill:#46b"/>
</svg>
text
</span>
Not sure how to add that to my current css ALSO TRIED
display: block;
clear: both;
width: 70%;
height: 2%;
float:right;
margin-top: -50%;
margin-right: 2%;
border-left: 10px solid transparent;
border-top: 4px solid #546aa4;
border-bottom: 4px solid #546aa4;
Issue with above is that my text has no background anymore... if I use background-color, then I will have to use border-left: 10px solid white, which is not going to look good on different background images as this layer will sit on top on an image.
With "I don't want to use an image in my app" being a rather vague requirement, you may find data URIs an appropriate alternative:
I'm a big fan of using these sparingly - they remove the need of an additional http request if the image is external, they do not require as much rendering resources on the client as heavy sprites would and they are (except for most trivial cases with the graphics simpler than yours) faster to render than CSS3 effects.
Edit: base64 encoding is part of some LESS/SASS css pre-processing implementations and there are online encoders available for one-off usage, for instance this one (just remember to remove all line breaks from the data uri)
Fiddled
If you have
<div class="magic">
, you could apply this style:Change dimensions to your own taste. This trick is called CSS Triangle.
jsFiddle Demo
EDIT: Or a quick demo with a transparent arrow - here you basically use different border colors for the tricky borders and a way to move the arrow to the left - I used
position: relative
- so the div's background won't cover what is underneath.