Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create shape with text in CSS3 or SVG or HTML(5)?

I need to create an HTML page as shown in the following image.

I don't know how to create clickable forms containing text.

The text should not be an image and not exceed its area (like an overflow: hidden)

I tried areas and maps in HTML but it is not possible to put text inside.

How to do that please ?

enter image description here

EDIT :

I tried something else with SVG after reading the Phrogz's answers but my text is out of my triangle ? I don't understand why.

Demo (check at the bottom) : http://jsfiddle.net/r7Jyy/3/

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0)   -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Calque_1" 
 xmlns="http://www.w3.org/2000/svg" 
 xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="960px" height="560px" 
 viewBox="0 0 960 560" 
 style="enable-background:new 0 0 960 560;" xml:space="preserve">
   <g>
      <polygon style="fill-rule:evenodd;clip-rule:evenodd;fill:none;" points="524.131,495.773 524.771,495.615 524.179,495.282 "/>
      <polygon style="fill-rule:evenodd;clip-rule:evenodd;fill:#CCC;" points="569.476,-10 212.575,320.5 524.179,495.282 572.75,-1.521 "/>
   </g>
   <text transform="matrix(1 0 0 1 236 255)">
      <tspan x="0" y="0" style="fill:#888; font-family:'Arial'; font-size:36.0467;">500% </tspan>
      <tspan x="0" y="30.039" style="fill:#888; font-family:'Arial'; font-size:36.0467;">New</tspan>
    </text>
 </svg>
like image 772
Steffi Avatar asked May 06 '13 16:05

Steffi


Video Answer


1 Answers

Here's an SVG example using clipping paths to clip text to arbitrary regions:

Demo: http://jsfiddle.net/r7Jyy/

<svg xmlns="http://www.w3.org/2000/svg">
  <defs><clipPath id="triangle1">
    <polygon points="10,30 180,60 250,10"/>
  </clipPath></defs>
  <polygon points="10,30 180,60 250,10" fill="none" stroke="black"/>
  <text x="20" y="50" clip-path="url(#triangle1)">Hello World</text>
</svg>

Use SVG's filter effects to create the embossed, inner shadow result on your text. Here's an example (that does not exactly match your needs): http://www.w3.org/2002/05/text.svg

like image 173
Phrogz Avatar answered Sep 25 '22 07:09

Phrogz