4

1. Summary

Gradiented text successful wrap by lines for me in Firefox, but not in another browsers.


2. Requirements

I need, that text gradient successful works in latest at April 2018 versions of these desktop and mobile browsers:

  • Firefox
  • Chrome
  • Safari
  • Opera

Internet Explorer and Opera Mini support not obligatory.

Any CSS or JavaScript/JQuery method will be suitable for me.


3. Example

Example: I need, that gradiented text Suricate: Sacagawea: Blitz/Supeblitz/Brain Ring text wrap by lines.

my code:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <title>
            Document
        </title>
        <style>
        em {
         background-image: -webkit-gradient(linear, left top, right top, from(red), to(black));
         background-image: linear-gradient(to right, red, black);
         -webkit-background-clip: text;
         color: transparent;
         font-size: 5rem;
        }
                </style>
    </head>
    <body>
        <em>
            Suricate: Sacagawea: Blitz/Supeblitz/Brain Ring
        </em>
    </body>
</html>

4. Expected behavior

(I use BrowserStack for cross-browser testing)

  • Samsung Galaxy S8, Android Nougat, Firefox 51:

Firefox


5. Non-expected behavior

  • macOS High Sierra, Safari 11:

macOS Safari

  • Samsung Galaxy S8, Android Nougat, Chrome 63:

Chrome

iOS Safari


6. Not helped

In all cases I get behavior as in Non-expected behavior section.

6.1. Prefixes

Different prefixes as in this answer.

6.2. CSS wrapping

overflow-wrap, word-break, word-wrap as in this article:

em {

  overflow-wrap: break-word;
  word-wrap: break-word;

  -ms-word-break: break-all;
  word-break: break-all;
  word-break: break-word;

}

6.3. Gradient.Text.js

As in this article:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <title>
            Document
        </title>
        <style>
         em {
          font-size: 5rem;
         }
        </style>
        <script src="//cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/gradient-text/dist/jquery.gradient.text.min.js"></script>
    </head>
    <body>
     <em class="gradient-text"
       data-gradient-text-range="#f00, #000">Suricate: Sacagawea: Blitz/Supeblitz/Brain Ring</em>
    </body>
</html>
Саша Черных
  • 2,561
  • 4
  • 25
  • 71
  • I have no way of testing this but one thing i always try, if the different word breaks and wraps don't work, is the 'white-space' property. – wazz Apr 29 '18 at 08:01
  • @wazz: **Status: Still doesn't work for me** | **Steps to reproduce**: I try add to code in 3 item of my question [**all values of `white-space` property**](https://www.w3schools.com/cssref/pr_text_white-space.asp). **Testing environment**: macOS High Sierra, Safari 11. Thanks. – Саша Черных Apr 30 '18 at 12:31

1 Answers1

1

This is the fix:

-webkit-box-decoration-break: clone;

I almost cried with joy when I found this.

Simon

Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55
SiDev
  • 19
  • 1