15

Is it possible in css make a single character in 2 colors?

I mean for example character "B" The first upper half in RED and the second half in BLUE

Apoleo
  • 2,045
  • 2
  • 21
  • 37
  • 1
    no, it is not possible, maybe you can try to superimpose two B letters and hide the top half for one, and the bottom half of the second one.. – Mazeltov Mar 05 '14 at 10:55
  • 3
    take a look at http://stackoverflow.com/questions/6258690/is-there-any-way-to-change-the-color-of-text-halfway-through-a-character-on-a?rq=1 – keuleJ Mar 05 '14 at 11:09

2 Answers2

3
h1 {
  font-size: 72px;
  background: -webkit-linear-gradient(red 49%, blue 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

Fill in your own vendor prefixes.

slynagh
  • 601
  • 4
  • 16
2

One solution would be:

HTML:

<span class="half" title="B">B</span>

(see that you have to set an attribute value)

CSS:

  .half {
        font-size: 90px;
        font-weight: bold;
        position: relative;
        color: blue;
        line-height: 1em;
    }

    .half:before {
        position:absolute;
        content:''attr(title)'';
        color: red;
        height: .5em;
        overflow: hidden;
    }

The problem is that every browser calculates the .5em value differently

Iulian Anghel
  • 411
  • 2
  • 5