Am in a need to provide outlines for text. These text say for eg: can be League name like Barclays Premier league, National Football League etc.
The closest i came with cross browser support is from the link below
https://www.alphachannelgroup.com/almost-cross-browser-text-stroke-outline-text/
but i would need thickness of outline that can vary between 10 - 20 pixels,
which am struggling to do. Please help
This is what i did
<style>
.element {
width: auto;
height: auto; /* width/height so IE7 and lower will work */
filter: glow(color=black,strength=1);
text-shadow: -10px -10px 0 #000,
10px -10px 0 #000,
-10px 10px 0 #000,
10px 10px 0 #000;
font-size:56px;
font-weight:bold;
color:#FFF;
}
</style>
and my div is
<div class="element">Hello Stranger</div>
and my output is blurry the screenshot is given below.
http://screencast.com/t/v9WPv9saYoS
the output am trying to get is given below
http://screencast.com/t/lMe1bubFht
the outline which is in color blue must be more thicker for me say 10px or 20px
thats what am trying to achieve.
UPDATE
failing to do so with text-shadows. am now trying cavas methods given link below
http://www.html5canvastutorials.com/tutorials/html5-canvas-text-stroke/
but still the thickness seems a problem i adjusted lineWidth to 10 and well it just
didnt work.... may be there exists some other option in canvas..if someone knows plese help.
Although -webkit-text-stroke is still non-standard feature and is not recommended for production, it has very good support in all modern browsers.
To make edges softer you can add multiple shadows with blur-radius equal to 0.5 of text-stroke-width. Also it would be good enough fallback for IE and Opera Mini (see the snippet).
#import url("https://fonts.googleapis.com/css?family=Permanent+Marker&display=swap");
p {
font-family: sans-serif;
font-size: 80px;
line-height: 80px;
color: #eee;
}
.p1 {
font-family: "Permanent Marker";
}
.p2 {
font-family: sans-serif;
font-weight: 700;
}
.stroke {
text-stroke: 6px black; /* doesn't work yet, requires -webkit- */
-webkit-text-stroke: 6px black;
}
.shadow {
text-shadow: 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black, 0 0 3px black
}
<p class="p1 stroke">Text-Stroke 123 456 789 0</p>
<p class="p1 stroke shadow">Text-Stroke 123 456 789 0 + Shadow</p>
<p class="p2 stroke">Text-Stroke 123 456 789 0</p>
<p class="p2 stroke shadow">Text-Stroke 123 456 789 0 + Shadow</p>
<p class="p1 shadow">Fallback 123 456 789 0</p>
<p class="p2 shadow">Fallback 123 456 789 0</p>
Such a big stroke will never look good with text-shadow unfortunately. There is text-stroke, but only working with -webkit prefix (and not for IE or Opera), you can check out my demo:
http://jsfiddle.net/hmyXX/
.one {
font-size: 8em;
color:white;
-webkit-text-stroke: 5px white;
-webkit-text-fill-color: black;
}
.two {
font-size: 7em;
font-weight: bold;
text-shadow:
3px 3px 0 #fff, -3px -3px 0 #fff, 3px -3px 0 #fff,
-3px 3px 0 #fff, 0px 0px 0px #fff;
}
Your desired stroke would be bigger than the letter spacing, making it impossible to achieve with pure CSS. Maybe just have that as an image or less stroke if possible?
Browser support improved a lot, only IE and Opera don't support it yet, see
https://caniuse.com/#feat=text-stroke .
There is a handy sass mixin which offers cross-browser text stroke, see
https://github.com/hudochenkov/sass-text-stroke .
#import "~sass-text-stroke/_text-stroke";
p {
#include text-stroke(4, #369);
}
Related
I have some outlined text on a website, but the text is now appearing weirdly for some reason. Have a look at the image link below for additional detail.
Specs:
WordPress 5.8.3
Elementor / Pro 3.5.3 / 3.5.1
Font: Sinkin Sans
Here's the code (no h1 in real code)
.cleartext {
color: #000000;
-webkit-text-fill-color: transparent;
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #000000;
}
.gbtext {
font-weight: 700;
}
<h1><span class="cleartext gbtext">It's clear</span> when you blah blah blah.</h1>
This is what I'm seeing:
the font lines are entering the space that should be transparent
It was the font, Sinkin Sans. It's not compatible. Changing it to Helvetica fixed it and it's close enough to Sinkin that most people probably wouldn't notice.
helvetica is a bit narrower and the periods/dots are squared, but not bad
It's because of the font. You cannot do probably anything and strokes on this font will be like on your img. But if you use text-shadow instead of -webkit-text-stroke, it's hack a little bit, but it should work. The main cons is that the text cannot be transparent, because of shaddows, they will be visible, so you must set color of the text.
.cleartext {
color: #fff;
text-shadow: 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000, 1px 0px 0 #000, 0px 1px 0 #000, -1px 0px 0 #000, 0px -1px 0 #000;
}
.gbtext {
font-weight: 700;
}
<h1><span class="cleartext gbtext">It's clear</span> when you blah blah blah.</h1>
When applying CSS text-shadow to an element that has its text content partially wrapped in child elements, the letters after the wrapped text will throw a shadow on the wrapped elements, as you can see in this example:
* {
font-family: sans-serif;
font-weight: 900;
}
.shadow {
color: #ffd9e2;
font-size: 3rem;
text-shadow: 0 0 0 transparent, 0 0 10px #ff003c, 0 0 20px rgba(255, 0, 60, 0.5), 0 0 40px #ff003c, 0 0 100px #ff003c, 0 0 200px #ff003c, 0 0 300px #ff003c, 0 0 500px #ff003c, 0 0 1000px #ff003c;
}
hr {
margin: 2em 0;
}
<span class="shadow">This <span>t</span>ext <span>c</span>onsists of multiple elements</span>
<hr>
<span class="shadow">This text consists of one single element</span>
The first "t" of "text" and the "c" of "consists" appear darker than the rest of the text due to this. The rendering engines (testet FF and Chrome latest) also seem to break up multiline text for rendering, so a new line will throw a shadow on the line before, but that's not even bothering that much here. However, I would like to have all characters of the text to be regarded as being on the same layer.
Is there some trick you can apply to the CSS to make the rendering behave that way?
I played around with z-index and wrapping all text nodes in child elements of the .shadow container, but to no avail.
You can consider drop-shadow() filter but pay attention as it doesn't work the same as text-shadow. Filter are cumulated and not applied seperately:
* {
font-family: sans-serif;
font-weight: 900;
}
.shadow {
color: #ffd9e2;
font-size: 3rem;
filter:
drop-shadow(0 0 10px #ff003c)
drop-shadow(0 0 20px rgba(255, 0, 60, 0.5))
drop-shadow(0 0 40px #ff003c);
}
hr {
margin: 2em 0;
}
<span class="shadow">This <span>t</span>ext <span>c</span>onsists of multiple elements</span>
<hr>
<span class="shadow">This text consists of one single element</span>
To better illustrate the effect of multiple drop-shadow() filter:
.box {
padding:50px;
font-size:30px;
font-weight:bold;
}
.s {
text-shadow: 20px 50px 0 red,150px -20px 0 blue,-20px 20px 0 green;
}
.f {
filter: drop-shadow(20px 50px 0 red) drop-shadow(150px -20px 0 blue) drop-shadow(-20px 20px 0 green);
}
<div class="box s">some shadow</div>
<div class="box f">some filter</div>
You can clearly see how many shadows we have in the second example because each time we consider the previous and we duplicate it.
You can use the drop-shadow() filter.
Demo:
* {
font-family: sans-serif;
font-weight: 900;
}
.shadow {
color: #ffd9e2;
font-size: 3rem;
filter: drop-shadow(0 0 0 transparent)
drop-shadow(0 0 10px #ff003c)
drop-shadow(0 0 20px rgba(255, 0, 60, 0.5));
}
hr {
margin: 2em 0;
}
<span class="shadow">This <span>t</span>ext <span>c</span>onsists of multiple elements</span>
<hr>
<span class="shadow">This text consists of one single element</span>
How would I make the image glow when hover? I would like to use white-color.
<img src="resources/img/email.png" class="img-circle">
image:
http://i.stack.imgur.com/Hx0kH.png
Can't post link. So, I would like to make it glow (inside), thanks. Any help would be great
I think what you are trying to do is accomplished with two versions of the same image (use of photo editing tools). Then use this code:
<img src="URL of darker image here"
onmouseover="this.src='URL of lighter image';"
onmouseout="this.src='URL of darker image here';">
</img>
You can give glow at the borders using
img:hover
{
-moz-box-shadow: 0 0 5px 5px #ddd;
-webkit-box-shadow: 0 0 5px 5px #ddd;
box-shadow: 0 0 5px 5px #ddd;
}
You can choose the color you want according to your requirements.
you can also visit http://codepen.io/anon/pen/ilqnb
or http://css3generator.com/
You can use box-shadow withInset property
.shadow { -moz-box-shadow: inset 0 0 10px #000000; -webkit-box-shadow: inset 0 0 10px #000000; box-shadow: inset 0 0 10px #000000; }
I am using -moz-border-top-colors for multiple border.
It works fine for Mozilla ,but
It does not work in other browsers.
however, I used -webkit ,still It did not work in Chrome.
this feature is supported by firefox only ... but you can use multiple shadows as a more cross-browser
solution
.box {
margin-top: 40px;
height: 200px;
width: 200px;
background: #ddd;
border-top: 3px solid blue;
/* custom borders */
box-shadow: 0 -3px 0 0 green,
0 -6px 0 0 black,
0 -9px 0 0 yellow,
0 -12px 0 0 skyblue;
}
check this link for more infos http://jsfiddle.net/8htrkqzb/
According to https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-border-top-colors this property is only supported in Firefox.
I was wondering what you guys think is the easiest way to get a double border with 2 colors around a div? I tried using border and outline together and it worked in Firefox, but outline doesn't seem to work in IE and that's sort of a problem. Any good ways to go about this?
This is what I had but outline does not work with IE:
outline: 2px solid #36F;
border: 2px solid #390;
Thanks.
You can add multiple borders using pseudo elements, and then place them around your original border. No extra markup. Cross-browser compatible, this has been around since CSS 2.1.
I threw a demo up on jsfiddle for you....note, the spacing between border colors is there for the example. You can close it by altering the number of pixels in the absolute positioning.
.border
{
border:2px solid #36F;
position:relative;
z-index:10
}
.border:before
{
content:"";
display:block;
position:absolute;
z-index:-1;
top:2px;
left:2px;
right:2px;
bottom:2px;
border:2px solid #36F
}
http://jsfiddle.net/fvHJq/1/
Use box shadow fo 2nd border.
div.double-border {
border: 1px solid #fff;
-webkit-box-shadow: 0px 0px 0px 1px #000;
-moz-box-shadow: 0px 0px 0px 1px #000;
box-shadow: 0px 0px 0px 1px #000;
}
In this case box-shadow does not ignore border-radius property like outline does
A very simple solution you could use as a fall-back if nothing else would be to use two divs. Your main div, and then an empty one just wrapping it that you could use to set the second border.
Late to the party for this question, but I feel like I should record this somewhere. You can make a scalable function in something like Less or Stylus which will create any number of borders (Stylus here):
abs(n)
if n < 0
(-1*n)
else
n
horizBorder(n, backgroundColor)
$shadow = 0 0 0 0 transparent
$sign = (n/abs(n))
for $i in ($sign..n)
/* offset-x | offset-y | blur-radius | spread-radius | color */
$shadow = $shadow, 0 (2*$i - $sign)px 0 0 #000, 0 (2*$i)px 0 0 backgroundColor
return $shadow
Then,
$background: #FFF // my background was white in this case and I wanted alternating black/white borders
.border-bottom
box-shadow: horizBorder(5, $background)
.border-top
box-shadow: horizBorder(-5, $background)
.border-top-and-bottom
box-shadow: horizBorder(5, $background), horizBorder(-5, $background)
With box-shadow you can achieve as many different color borders as you want. E.g:
#mydiv{
height: 60px;
width: 60px;
box-shadow: inset 0 0 0 5px #00ff00, inset 0 0 0 10px #0000ff;
}
<div id="mydiv"> </div>
https://jsfiddle.net/aruanoc/g5e5pzny
A little trick ;)
box-shadow:
0 0 0 2px #000,
0 0 0 3px #000,
0 0 0 9px #fff,
0 0 0 10px #fff,
0 0 0 16px #000,
0 0 0 18px #000;
.border{
width: 200px;
height: 200px;
background: #f06d06;
position: relative;
border: 5px solid blue;
margin: 20px;
}
.border:after {
content: '';
position: absolute;
top: -15px;
left: -15px;
right: -15px;
bottom: -15px;
background: green;
z-index: -1;
}
<div class="border">
</div>
use the class name for .border given the vales border:2px solid #000 for single border.then you want another border try to .border:after given the values if you got second border check out above the code sample
example