Category : Html | Author : Chtiwi Malek | First posted : 3/26/2013 | Updated : 9/7/2014
Tags : svg, css3, html5, fonts, text, clipping, cropping, masks, effects, design, tutorials
Text as Image Clipping Mask (Fill text background with a picture)

Text as Image Clipping Mask (Fill text background with a picture)

Recently I was looking to fill a text's background (an online postcard title) with an image and I was looking for a cross-browser solution that would work well.

The Idea is to apply a text (font) as a layer mask over the image. Achieving this kind of effect using only HTML (in a cross-browser way without using Flash/Silverlight…) was not possible, but now with SVG this can be done very easily.

This is the image I will use to fill the text's background with :
 
 

The first solution I tested was to declare the image and the Svg mask definition in the html and in the Css code marry the image to the mask using the css ‘mask’ property.
#myImg {
  mask: url(#myMask);
}
This solution was perfect and straightforward but unfortunately it doesn’t work on webkit browsers like google chrome (the SVG code cannot be placed directly in the html, but need to be placed in an external svg file).

The 2nd solution I came up with to obtain the desired text effect, was to place an SVG object (containing the text mask) on the image. The SVG object can be placed directly on the image (using z-index), or inside a div containing the image in its background. in both cases the image should only be visible within the confine of the text's shape.

Here's the final result with the previous picture as the text's background :
The SVG text here have a 5px thick outline with a 100% transparency while the text fill have a 50% transparency value, the result is a nice hollow/glow like effect.

Html Code :
<div id="bkDiv">
  <svg width="100%" height="100%">
    <defs>
      <mask id="theMask">
        <rect width="100%" height="100%" fill="#fff" />
        <text x="0" y="120" id="theText" fill="#000">Codicode</text>
      </mask>
    </defs>
    <rect width="100%" height="100%" mask="url(#theMask)" fill="#000" />
  </svg>
</div>
Css Code :
#bkDiv
{
  background-image : url('my_image.jpg');
  height:130px;
  width:550px;
}

#theText
{
  font-size:140px;
  font-family:impact;
  stroke:#000;
  stroke-width:5px;
  fill-opacity:0.5;
}
We also can render effects and animations in the text background instead of a steady picture when using Css3, check this text background animation with svg and css3 tutorial.

Hope you like this and don't hesitate to comment and share, Thanks.
About the author :
Malek Chtiwi is the man behind Codicode.com
34 years old full stack developer.
Loves technology; but also likes design, photography and composing music.
Comments & Opinions :
Good article
A  very useful article i really like it. You can also find good articles there http://progbase.ru/
- by Dencuc on 6/21/2013
yueqin

cheap jordan sho

 

swarovski sale

 

bercrombie

 

yeezy shoes

 

polo ralph lauren outlet online

 

louboutin outlet

 

louis vuitton

 

longchamp pliage

 

coach handbags outlet

 

coach outlet store online

 

adidas running shoes

 

yeezy boost

 

fitflops

 

coach factory outlet store

 

true religion jeans

 

coach outlet canada

 

kate spade handbags

 

air max outlet

 

michael kors bags

 

michael kors

 

jimmy choo shoes

 

ed hardy uk

 

air jordans

 

coach outlet store online clearance

 

christian louboutin outlet

 

jordan retro

 

christian louboutin outlet

 

swarovski uk

 

birkenstock outlet

 

burberry sale

 

michael kors outlet clearance

 

tory burch outlet online

 

michael kors purses

 

michael kors outlet online

 

louis vuitton outlet online

 

marc jacobs

 

marc jacobs outlet

 

adidas sneakers

 

coach factory outlet

 

jordan femmes pas cher

 

kate spade outlet store

 

discount oakley sunglasses

 

michael kors outlet store

 

ralph lauren sale

 

jerseys cheap

 

polo ralph lauren outlet online

 

pandora charms sale

 

michael kors outlet clearance

 

beats wireless headphones

 

kd 8 shoes

 

birkenstocks

 

coach outlet online

 

coach factory outlet online

 

nike sneakers

 

coach factory outlet

 

michael kors outlet clearance

 

tommy hilfiger windbreaker

 

christian louboutin

 

cheap rolex watches

 

fitflops

 

sac louis vuitton

 

kate spade

 

kate spade outlet online

 

toms outlet

 

louis vuitton purses

 

timberland boots outle

 

nike uk

 

coach outlet online

 

fitflop shoes

 

gucci

 

cheap oakley sunglasses

 

coach factory outlet

 

air max 90

 

coach outlet online

 

michael kors handbags clearance

 

ralph lauren uk

 

polo ralph lauren outlet online

 

celine outlet online

 

nike outlet store

 

kate spade outlet

 

discount oakley sunglasses

 

michael kors

 

moncler jackets

 

rolex replica watches

 

rangers jerseys

 

birkin handbags

 

coach outlet online

 

louis vuitton factory outlet

 

tory burch sale

 

ralph lauren outlet online

 

birkenstock outlet

 

christian louboutin outlet

 

true religion jeans outlet

 

michael kors

 

cheap oakley sunglasses

 

yeezy boost 350

 

longchamp handbags

 

cheap oakley sunglasses

 

red bottom shoes for women

 

michael kors outlet clearance

 

coach factory outlet online

 

cardinals jerseys

 

ray bans

 

ghd straighteners sale

 

fendi bags

 

nike outlet

 

coach outlet store

 

adidas outlet store

 

cheap oakley sunglasses

 

yeezy boost 350 v2

 

adidas sneakers

 

red bottom

 

tods shoes

 

mulberry uk

 

pandora bracelet

 

thunder jerseys

 

sac longchamp

 

cheap nfl jerseys

 

christian louboutin uk

 

ralph lauren

 

true religion

 

tommy hilfiger outlet

 

ralph lauren outlet online

 

oakley sunglasses outlet

 

longchamp bags

 

coach outlet store online

 

eahawks jerseys

 

yeezy boost

 

louboutin shoes

 

jordan uk

 

coach factory outlet online

 

birkenstock

 

tods outlet

 

coach factory outlet

 

louboutin outlet

 

michael kors

 

hermes bags

 

pandora charms sale

 

rolex replica watches for sale

 

polo ralph lauren

 

rolex watches

 

coach outlet online

 

michael kors

 

pandora charms

 

louis vuitton factory outlet

 

mont blanc pens

 

phillies jerseys

 

ed hardy outlet

 

michael kors outlet online

 

fred perry polo shirts

 

ralph lauren outlet

 

longchamp handbags

 

michael kors outlet store

 

nike free run

 

michael kors outlet clearance

 

cheap oakley sunglasses

 

michael kors outlet online

 

nike sneakers

 

49ers jerseys

 

polo ralph lauren outlet

 

nike flyknit

 

rolex watches

 

toms outlet store

 

ralph lauren outlet online

 

cheap ray ban sunglasses

 

cheap jordan shoes

 

coach outlet online

 

fitflops sale

 

adidas yeezy boost

 

michael kors outlet

 

gucci bags

 

true religion jeans outlet

 

fitflops sale clearance

 

longchamp sale

 

adidas yeezy boost

 

louis vuitton outlet online

 

birkenstock shoes

 

michael kors outlet canada

 

swarovski crystals

 

ray ban sunglasses sale

 

cowboys jerseys

 

ralph lauren sale clearance uk

 

mbt

 

polo ralph lauren outlet online

 

nike tn pas cher

 

ghd hair

 

air max

 

pandora jewellery

 

coach factory outlet

 

fred perry polo shirts

 

michael kors outlet store

 

michael kors

 

longchamp bags

 

nfl jerseys wholesale

 

adidas nmd r1

 

michael kors bags

 

lakers jerseys

 

ray ban sunglasses outlet

 

longchamp soldes

 

moncler uk

 

air max 90

 

christian louboutin sale

 

coach outlet online

 

yeezy boost

 

beats headphones

 

cheap nike shoes

 

coach outlet store

 

adidas nmd runner

 

true religion sale

 

rockets jerseys

 

pandora jewelry store

 

coach outlet store online

 

louis vuitton handbags

 

nike air max 95

 

curry shoes

 

mlb jerseys

 

michael kors outlet online

 

oakley sunglasses wholesale

 

michael kors outlet online

 

dolce and gabbana outlet online

 

michael kors outlet canada

 

prada outlet online

 

michael kors outlet store

 

coach outlet online

 

fit flops

 

discount oakley sunglasses

 

adidas nmd runner

 

pandora charms outlet

 

moncler jackets

 

chaussures louboutin

 

texans jerseys

 

lebron shoes

 

red sox jerseys

 

michael kors

 

parada bags

 

air max shoes

 

nike blazer low pas cher

 

pandora jewelry outlet

 

purs jerseys

 

oakley sunglasses outlet

 

dodgers jerseys

 

michael kors bags

 

versace

 

mont blanc pen

 

kate spade purses

 

michael kors bags

 

michael kors outlet store

 

moncler outlet online

 

moncler uk

 

adidas nmd r1

 

louboutin outlet

 

cheap rolex replica watches

 

air max 90

 

fitflops clearance

 

discount oakley sunglasses

 

levis outlet

 

cheap air max

 

adidas nmd r1

 

coach outlet online

 

longchamp handbags

 

yeezy shoes

 

jordan shoes

 

fitflops sale

 

pandora charms outlet

 

ralph lauren uk

 

discount nike shoes

 

coach factory outlet

 

mont blanc pen

 

true religion outlet online

 

adidas superstar shoes

 

nike outlet

 

ralph lauren outlet online

 

adidas uk

 

true religion outlet store

 

nike store

 

polo ralph lauren outlet online

 

true religion outlet store

 

coach factory outlet

 

nike outlet store online

 

birkenstock uk

 

coach outlet online

 

fitflop shoes

 

coach factory outlet online

 

nike cortez classic

 

ray bans

 

michael kors outlet store

 

moncler coats

 

adidas outlet online

 

michael kors uk

 

christian louboutin shoes

 

adidas nmd runner

 

christian louboutin

 

adidas nmd r1

 

louboutin shoes

 

hermes outlet online

 

cubs jerseys

 

polo ralph lauren

 

coach factory outlet online

 

nmd adidas

 

giants jerseys

 

pandora charms

 

kate spade outlet online

 

nfl jerseys wholesale

 

jordans

 

warriors jerseys

 

polo ralph lauren

 

true religion jeans outlet

 

polo ralph lauren

 

birkenstock outlet

 

coach factory outlet

 

gucci outlet online

 

cheap nike sneakers

 

vans outlet

 

mulberry outlet uk

 

cheap jerseys

 

cheap oakley sunglasses

 

ray ban sale

 

white sox jerseys

 

toms outlet

 

coach purses

 

valentino outlet

 

mulberry

 

coach factory outlet online

 

kate spade bags

 

nike roshe shoes

 

mlb jerseys

 

ray ban sunglasses discount

 

coach factory outlet online

 

michael kors outlet online

 

mlb jerseys

 

coach outlet online

 

coach outlet online

 

polo ralph lauren

 

chi flat iron

 

louis vuitton outlet online

 

mulberry handbags

 

adidas superstars

 

fitflop

 

burberry outlet online

 

nfl jerseys cheap

 

kate spade bags

 

coach outlet online

 

christian louboutin sale

 

louboutin outlet

 

ray ban glasses

 

cavaliers jerseys

 

ray ban sunglasses outlet

 

polo ralph lauren outlet

 

michael kors handbags outlet

 

michael kors outlet store

 

nike air max 95

 

yeezy boost 350

 

louboutin pas cher

 

discount oakley sunglasses

 

sac longchamp

 

cheap jordan shoes

 

air jordans

 

michael kors outlet online

 

michael kors outlet store

 

pandora jewelry

 

james shoes

 

coach outlet

 

michael kors handbags outlet

 

nike free 4.0 flyknit

 

true religion uk

 

adidas outlet online

 

michael kors uk

 

pandora outlet

 

yeezy shoes

 

toms

 

michael kors outlet online

 

cheap jordan shoes

 

coach outlet online

 

eltics jerseys

 

polo ralph lauren pas cher

 

polo ralph lauren outlet

 

ralph lauren sale

 

mlb jerseys

 

ralph lauren outlet online

 

longchamp bag

 

adidas yeezy boost

 

polo ralph lauren outlet

 

christian louboutin pas cher

 

coach outlet online

 

hollister clothing

 

pandora charms sale clearance

 

coach outlet store online

 

coach outlet store

 

cheap jerseys

 

michael kors handbags outlet

 

wireless beats headphones

 

kate spade uk

 

coach outlet online

 

oakley sunglasses cheap

 

longchamp outlet store

 

coach outlet online

 

pandora jewellery

 

adidas yeezy boost 350

 

adidas nmd runner

 

true religion jeans outlet

 

pandora charms sale clearance

 

adidas

 

cheap oakley sunglasses

 

coach outlet online

 

toms shoes

 

kate spade outlet online

 

celine handbags

 

yeezy boost 350

 

pandora charms sale clearance

 

mulberry bags

 

coach factory outlet online

 

pandora

 

cheap oakley sunglasses

 

gucci bags

 

beats by dre

 

coach outlet store

 

toms

 

michael kors outlet

 

adidas sneakers

 

coach factory outlet online

 

sac louis vuitton pas cher

 

moncler pas cher

 

patriots jerseys

 

ray ban sunglasses discount

 

longchamp bag

 

michael kors outlet store

 

gucci handbags outlet

 

coach outlet online

 

coach outlet online

 

nike air huarache

 

montblanc pens

 

chaussures louboutin

 

michael kors outlet online

 

coach factory outlet online

 

kate spade outlet online

 

oakley sunglasses outlet

 

nike air force

 

michael kors

 

kd shoes

 

michael kors outlet clearance

 

pandora uk

 

birkenstocks

 

nfl jerseys

 

fred perry shirts

 

oakley sunglasses on sale

 

pandora charms outlet

 

montblanc

 

chaussure louboutin pas cher

 

louis vuitton outlet store

 

rolex replica watches for sale

 

abercrombie outlet

 

pandora jewelry

 

adidas outlet store

 

gucci

 

yeezy boost 350

 

ralph lauren

 

coach outlet

 

red bottom

 

pandora jewelry outlet

 

bulls jerseys

 

coach outlet store

 

coach factory outlet online

 

gucci handbags outlet

 

hollister clothing store

 

polo ralph lauren outlet online

 

nike free run flyknit

 

fit flops

 

fit flops

 

adidas trainers

 

michael kors bags

 

coach outlet store online

 

burberry outlet

 

tigers jerseys

 

air max

 

fitflops sale

 

mulberry uk

 

gucci outlet online

 

longchamps

 

nike roshe one

 

coach factory outlet online

 

tory burch outlet online

 

michael kors outlet store

 

christian louboutin shoes

 

adidas

 

cheap jordan shoes

 

adidas ultra boost

 

coach outlet online

 

ed hardy store

 

broncos jerseys

 

toms

 

louis vuitton outlet store

 

ralph lauren outlet

 

coach factory outlet online

 

vans store

 

nike outlet online

 

ralph lauren sale clearance uk

 

longchamp bags

 

yankees jerseys

 

hollister kids

 

nike air max

 

kobe bryant shoes

 

coach outlet store online

 

michael kors purse

 

ralph lauren outlet

 

adidas trainers

 

adidas superstar trainers

 

fake rolex watches

 

packers jerseys

 

coach outlet online

 

yeezy boost

 

ray ban glasses

 

ed hardy clothing

 

ralph lauren sale

 

nike outlet store

 

true religion jeans outlet

 

pandora charms sale clearance

 

cheap nfl jerseys

 

coach outlet online

 

christian louboutin outlet

 

michael kors outlet store

 

adidas store

 

pandora charms

 

fitflops sale clearance

 

michael kors handbags

 

heat jerseys

 

cheap ray ban sunglasses

 

adidas yeezy boost

 

pandora charms

 

coach outlet online

 

jordan shoes

 

polo ralph lauren outlet

 

gucci borse

 

air max

 

louis vuitton bags

 

louis vuitton outlet online

 

coach factory outlet online

 

hermes bags

 

cheap jordans for sale

 

yeezy 350 boost

 

polo ralph lauren outle

 

red bottom heels

 

adidas superstars

 

michael kors outlet online

 

harden shoes

 

michael kors outlet online

 

nike outlet store

- by 20170419 yueqin on 4/19/2017
Leave a Comment:
Name :
Email : * will not be shown
Title :
Comment :


» Member access