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.
Here is a good start of what you can do.
See: In Action
It seems that you want a vectorial image. You can use the HTML svg tag to create a polygon:
http://jsfiddle.net/XDtXV/
In the sense that HTML elements can be styled, yes, a shape like that could be created. You'd have to use multiple DIVs to accomplish it. Here's a site that gives a nice overview of creating basic geometric shapes using border styles:
http://css-tricks.com/examples/ShapesOfCSS/
I've yet to see an approach using pseudo elements here, so I thought I'd add one here. This is presuming that you're giving your div a set height:
If all you want to do is avoid linking to an external image file you could embed the image in your css or html directly.
Here's an example:
In this case I used the image data URL for the background-image css property, but you could also use the same URL for the
src
attribute of an<img>
tag.Here's an example to get you started:
HTML:
CSS:
Fiddle link: http://jsfiddle.net/kHDFp/