How to make see through text?
What you're trying to achieve is possible with CSS. With background-clip: text
, you can use a background for the text but you will have to align it with the background of the page.
Here's an example:
body { background: url(http://o.homedsgn.com/wp-content/uploads/2011/04/NYC-at-Night-54.jpg) no-repeat; margin: 10px; background-position: center top;}h1 { background-color: rgba(255, 255, 255, 0.7); overflow: hidden; text-align: center; padding: 10px; font-weight: bold; font-family: arial; font-size: 83px; margin: 450px 0px 0px 0px; }span { background: url(http://o.homedsgn.com/wp-content/uploads/2011/04/NYC-at-Night-54.jpg) no-repeat; -webkit-text-fill-color: transparent; -webkit-background-clip: text; display: block; background-position: center -450px;}
<h1><span>NEW YORK</span></h1>
How to change text transparency in HTML/CSS?
opacity
applies to the whole element, so if you have a background, border or other effects on that element, those will also become transparent. If you only want the text to be transparent, use rgba
.
#foo {
color: #000; /* Fallback for older browsers */
color: rgba(0, 0, 0, 0.5);
font-size: 16pt;
font-family: Arial, sans-serif;
}
Also, steer far, far away from <font>
. We have CSS for that now.
How to make text transparent (HTML/CSS)
One trick is to cut out the background of an element using text masking.
In this case we give the a elements within each li the same background (i.e. animation) as you've given the body.
Make the color in the a element transparent and it will mask out its background, making it look as though the background is the same as the body.
body {
animation: 10000ms ease-in-out infinite color-change;
padding: 5px 5%;
}
@keyframes color-change {
0% {
background-color: #0047ff;
}
50% {
background-color: #6f0ce8;
}
100% {
background-color: #0047ff;
}
}
ul {
list-style-type: none;
}
li a {
-webkit-background-clip: text;
background-clip: text;
color: transparent;
animation: 10000ms ease-in-out infinite color-change;
padding: 5px 5%;
}
#navbar {
font-weight: bolder;
font-size: 33px;
background-color: black;
color: white;
border-radius: 0.9rem;
margin: 0.9rem;
transition: 0.3s;
text-decoration: none;
}
<body>
<ul id="navbar">
<li><a href="mission.html">Dummy Text</a></li>
</ul>
</body>
transparent text but opaque background in css
I found an answer for my question here:
https://codepen.io/zFunx/pen/EbOQow
body { padding: 0; margin: 0; height: 100%;}.overlay { background: url(https://web.opendrive.com/api/v1/download/file.json/NTlfMTM2NDExNjNf?inline=1); height: 100%; position: relative; background-size: cover;}.overlay h1 { position: absolute; background-color: #000; color: #fff; mix-blend-mode: multiply; text-align: center; font-size: 3em; top: 50%; left: 50%; transform: translate(-50%, -50%);}
<div class="overlay"> <h1>Mix-Blending in CSS</h1></div>
How to make a text stroke with transparent text
You can achieve the transparent text with text-stroke with an inline svg.
You can use the <text>
element (more info on MDN) set the fill
property to none
or transparent
to make the text transparent and use the stroke
porperty to make the text outline. stroke-width
and stroke-color
can define the texte stroke thickness and color
Here is an example: transparent text with a white stroke and a background image showing through the text:
body { background: url('https://farm9.staticflickr.com/8760/17195790401_94fcf60556_c.jpg'); background-size: cover;}svg{width:100%;}
<svg viewbox="0 0 10 2"> <text x="5" y="1" text-anchor="middle" font-size="1" fill="none" stroke-width=".015" stroke="#fff" font-family="sans-serif">Text stroke</text></svg>
How to create transparent text on non-transparent background
You can use SVG to create a mask
with a rect
element for the white background and a text
element for transparent text part.
body { margin: 0; padding: 0; display: flex; align-items: center; justify-content: center; background: url('http://blog.oxforddictionaries.com/wp-content/uploads/mountain-names.jpg'); background-size: cover; height: 100vh; background-position: center; font-family: 'Open Sans', sans-serif;}
svg { width: 300px; height: 100px;}svg text { text-anchor: middle;}svg #overlay { fill: white; opacity: 0.7;}svg #text { font-size: 40px; font-weight: bold;}
svg #r { fill: white; mask: url(#mask);}
<svg> <defs> <mask id="mask" x="0" y="0" width="100%" height="100%"> <rect id="overlay" x="0" y="0" width="100%" height="100%" /> <text id="text" x="50%" y="0" dy="65px">Some text</text> </mask> </defs> <rect id="r" x="0" y="0" width="100%" height="100%" /></svg>
Making transparent text in CSS and fitting background image inside a text shape
Try this:
element.style {
color: rgba(0,0,0,0.0); /* for transparent color */
-webkit-text-stroke: 1px rgba(0,0,0,1.0); /* for solid black outline */
}
UPDATED
If you need background image though the text:
.bg-though-text { font-size: 50px; font-weight: 700; text-transform: uppercase; background: linear-gradient(45deg, #0B2349 33%, #0D61BC 66%, #8AA9D6); /* Here you can use an image bg */ /* This will start the magic */
-webkit-background-clip: text; /* This will bring bg shape according to text*/ -webkit-text-fill-color: transparent; /* This will make text color transparent */ color: rgba(0,0,0,0.0); /* This will make text color transparent for sure */}
<p class="bg-though-text">Gradient bg</p>
Related Topics
Load a Low-Res Background Image First, Then a High-Res One
What Does It Mean When The Form Action Attribute Is "#" (Number/Pound Symbol/Sign/Character)
How to Convert an HTML Table to Csv
Django Doesn't Display Newline Character When Rendering Text from Database
CSS/HTML: Create a Glowing Border Around an Input Field
Accessibility: Recommended Alt-Text Convention for Svg and Mathml
Right Align Text Within Bootstrap 4 Breadcrumbs
Send Form by Email and Track Responses in Spreadsheet
How to Hide The Arrow That Is Displayed by Default on The HTML5 <Details> Element in Chrome
Subpixel Anti-Aliased Text on HTML5's Canvas Element
Hide Element, But Show CSS Generated Content
Is It Ok to Have Multiple HTML Forms with The Same Name
Text Gradient with Font Awesome
Can a Div Have Multiple Classes (Twitter Bootstrap)
Why Isn't Textarea an Input[Type="Textarea"]
Bootstrap 3 Grid, Does It *Really* Matter How Many Columns Are in a Row
What Client-Side Web Scripting Languages Are There Other Than JavaScript and Vbscript