Safari doesn't render css gradient text - html

I'm trying to make gradient text in webkit browsers using this CSS code:
.text {
background: -webkit-linear-gradient(blue, green);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
it works perfectly in Chrome, but in Safari (both 8 and 9) it doesn't render gradient text unless you select it via mouse click+drag over it.
HTML is as follows:
<p class = "text">Hello world.</p>
Spent 2 evening on that. Found a lot of recommendations to use this method with couple issues similar to mine and no solutions at all. Would appreciate a lot if someone would help.
IMPORTANT UPDATE:
I've found out, that this code works great when applied to single <p> element, but fails to render in Safari (not in chrome) when applied to div wrapper to single or multiple <p> elements like this:
<div class = "text">
<p>First line.</p>
<p>Second, way longeeeeeeer line. </p>
<p>Third line, just to see gradient span over multiple lines. </p>
</div>
Any thoughts why this could be the case or how to overcome this?

I found a simple fix for this
.text, span {
display: block;
}

I know it's an old question but in case someone still needs it: I had the same problem and what worked for me was to add a text-shadow to it and make the shadow transparent.
.text {
background: -webkit-linear-gradient(blue, green);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-shadow: 0px 0px #00000000; <--
}
Note that I added '00' to the end of the HEXA code which leads to transparency if someone doesn't know!

If you code like this <h1>Discover <span>Something</span></h1> then text gradient won't appear in Safari but does appear fine in Chrome and Firefox.
If you do like this <h1>Discover Something</h1> without span tag then it does work properly. I don't think Safari liked tags inside the tag. Nasty bug. It works on other browsers like Chrome and Safari.

If you have a two lines text and in Safari does not works, try:
-webkit-box-decoration-break: clone;

flex or inline-flex are the problems if you are using it.
block or inline-block are fixing the problem

This remains a Safari bug as of May 2018. The gradient properly appears if the text is first highlighted, and then unhighlighted.
I was able to use the following alternative:
.text {
-webkit-mask-image: linear-gradient(blue, green);
}
This is working in Safari 11, iOS Safari 11, Chrome 66, and Firefox 60.
Inspired by https://stackoverflow.com/a/45136579/9772439

I had the same problem with b tag, and solve it with property
display: inline-block;

I had the same issue and it looks like it's a Safari bug.
I noticed that the issue only happens when your cascading elements are block types.
My hack for this went like this
<div class = "text">
<span>First line.</span>
<p></p>
<span>Second, way longeeeeeeer line. </span>
<p></p>
<span>Third line, just to see gradient span over multiple lines.</span>
<p></p>
</div>
The only reason I have the paragraph tags is for spacing since adding a display block on the spans will trigger the bug again.

For me, the easiest way to archive this is drawing text as image, contain shadow... And put it in background css.

If you have tried all of the above and none are working, check to see if you have a Pseudo element on the tag.
Safari doesn't like it if these are static so you'll need to position them absolute.

I have the same issue, for fix it use attribute display with the property "inline" or "inline-block" to the main element, in your case p.text

Related

Wrapping input placeholder text not working in Firefox

I am trying to get my placeholder text to wrap to the next line on an input field. I found examples on how to do this and it's working in Chrome but not Firefox.
This is the Stack Overflow question I took my code from:
Placeholder auto wrap inside a input field
That works for Chrome but not Firefox. I know my pseudo element is working because when I do something else obvious (i.e. color: red), that does change the input text. I am looking for help on the wrap stylings specifically.
::-moz-placeholder {
white-space:pre-line;
position:relative;
top:-7px;
}
(This doesn't work in FF)
::-webkit-input-placeholder {
white-space:pre-line;
position:relative;
top:-7px;
}
(This does work in Chrome)
I am looking to get the input placeholder to wrap down to the next line and not get cut off.
As far as I know Mozilla Firefox removed the ability to wrap the placeholder. The placeholder element is extremely tricky and technically not that well supported.
A solutions can be to remove placeholders entirely and rely on another option. Here's an article about (not) using the placeholder and its alternatives from Smashing Magazine.

-moz-background-clip:text does not work in Firefox

I'm trying to fill in the content of a text in a h1 tag by an image.
Following my understanding ;-), I'm doing the following in the html:
<div class="image_clip">
<h1>
MY WONDERFULL TEXT
</h1>
</div>
And in the css file:
.image_clip{
background: url(../images/default.png) repeat;
-moz-background-clip: text;
-moz-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
The fact is that it does not yield the expected result... that is the text with the image in it as color.
The image is displayed on the entire background of the div and not only behind the text.
The text itself is moreover still in black.
I'm trying that on Firefox. Don't have other browsers.
Did I missed something?
Tks for the help.
Whilst -webkit-background-clip:text exists, -moz-background-clip:text does not, so you won’t be able to achieve your clipping effect in Firefox. (Unless there’s another way I can’t think of.)
Neither does -moz-text-fill-color, although you could just use color:transparent, as long as the element doesn’t have anything else (e.g. borders, -wekbit-text-stroke) that you want to be visible.
Your code does work in Chrome and Safari:
http://jsfiddle.net/7T8am/2/
However, the <h1>’s text does need to be transparent, so if any other CSS code is setting a colour for the <h1>, you’ll need to override it.
Per the standard, the background-clip property (which is implemented without a prefix in Firefox, by the way), doesn't have text value. You're using a proprietary WebKit feature, not a standard CSS property....
You are applying the style to the enclosing div, not the h1 tag. Try changing your selector to be .image_clip h1 {your:styles;}, or alternatively you can leave your CSS the same and apply the class to the h1 with <h1 class="image_clip"></h1>.
To get background-clip:text to give the anticipated appearance in Firefox you could use this polyfill - https://github.com/TimPietrusky/background-clip-text-polyfill - that replaces the CSS with an SVG version in non Webkit browsers. [untested but seen working]

Strange white text in IE7 and IE8

I'm having a problem with some text that is meant to be black. Only in IE7 and IE8 is the text white (in IE6 it is black).
The text is in a paragraph within a slideshow and I've tried all I can think of; pointing at it very specifically with CSS and doing color:#000;. I also tried pointing at it with jQuery to no avail. When I load the page, it begins as black then instantly turns white.
Many Thanks
I finally cracked it! It was to do with a CSS opacity filter. It's strange though because the opacity filter was set to the element's sibling.
ex:
<h3 (opacity set on bg of this, given height, absolute position etc) >
Bla bla bla</h3>
<div (absolutely positioned above h3 sibling) >
<div>
<p>Problem text here</p>
</div>
</div>
I tried setting the z-index of the div to be on top of the h3 but it doesn't work in IE8 and 7. Anyway, applying filter:none; in my IE8 stylesheet HAS worked! :)
try giving the p tag direct styling
<p style="color: #000 !important;">hjskhjakfhjkshfjdhkja</p>
Okay maybe another try:
You said it switches to white suddenly... Do you have some code in your jQuery file, that triggers after the page is loaded completely?
And another way to find out where the problem is located: disable js or css in the development settings and see what happens.

Problem in firefox vs chrome with bold text and double borders

I'm working on a site and I have some problems that I hope you guys can help me with :)
If I put bold on my text in the menu it looks too bold in Firefox :S, but it looks fine in Chrome.
In Firefox the double border on the #content container is outside of the shadow effect :S, but looks good in Chrome.
Screen shot on Mac Firefox 5.0.1 and Chrome 13.0.782.112:
This is my project.
I hope some one can help me out with this.
If you have something I better I can do, I will be glad to hear that too :)
Your first issue regarding bold font looking different between the browsers is just because of the way browsers render text differently. There is nothing you can do about it, unless you go the horrible route of using images instead.
Your second issue is not about the border but rather the outline. It is caused because of the way Firefox interprets the outline when box-shadow is applied. It applies it outside of the shadow instead.
You can put the code below in your css to target Firefox and bring the outline back in:
#-moz-document url-prefix() {
#content{
outline-offset: -11px;
}
}
Live example: http://jsfiddle.net/tw16/n8bet/
#1: There differences in font rendering in every browser. You can try numeric values instead of simply bold to narrow the results ( http://clagnut.com/blog/2228/ ). Also read the answer on this SO entry: Same font except its weight seems different on different browsers
#2: remove this line from #content css:
outline: 1px solid #B9BDBE;

Box Shadow in CSS internet Explorer 8 problem

I have a question about IE8 with css. I pasted code in my css from msdn
.shadow {-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";}
I used the problem code like this
<div class="shadow"> <p>Bla Bla</p> </div>
And i have a problem about that. I want only DIV has shadow but "Bla Bla" has shadow too.
Can anyone suggest a method to fix this issue?
Thanks...
You need to specify a background color for your element:
http://jsfiddle.net/UNKAc/14/
.shadow {
background:#fff;
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";
}
Don't quote me on this but: i think this is because IE tries to cast a light that need a solid to drop a shadow. And since your div is transparent atm the only thing that can cast a shadow is the text itself.
You could apply background-color: #fff to your div, then you won't be able to see the shadow drawn by the text.
However, the filter doesn't look as good as box-shadow from CSS3.
IE8 does not support box-shadow, but you can emulate it with CSS3 PIE.
I know this is a couple weeks old, but if you're still tweaking at all you should really look at CSS3 PIE. One of my friends here at work showed it to me and it's pretty great if you can rely on JS for these types of enhancements for IE.
http://css3pie.com/documentation/pie-js/