soundswaste
soundswaste

Reputation: 3074

Rotated text is breaking

I am trying to use Chris Coyier's CSS to put corner-ribbons on my divs..

.ribbon-wrapper-green {
  width: 85px;
  height: 88px;
  overflow: hidden;
  position: absolute;
  top: -3px;
  right: -3px;
}

.ribbon-green {
  font-size: 10px;
  font-weight:bold;
  color: #111;
  text-align: center;
  text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg);
  position: relative;
  padding: 3px 0;
  left: -5px;
  top: 15px;
  width: 120px;
  background-color: #BFDC7A;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45)); 
  background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45); 
  background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45); 
  color: #6a6340;
  -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
}

The problem is that, when small and rotated, the text seems to break.

Here's the Fiddle :

http://jsfiddle.net/H6rQ6/8728/

If its not breaking in your browser, here's a snapshot of what i am facing :

enter image description here

Upvotes: 0

Views: 1229

Answers (3)

soundswaste
soundswaste

Reputation: 3074

I resolved this problem, thanks to showdev, by using

-webkit-transform: rotate(45deg) translate3d( 0, 0, 0);

That's because fonts are antialiased by default in chrome, and using translated3d(0,0,0) smoothens them.

More here : Wonky text anti-aliasing when rotating with webkit-transform in Chrome

Upvotes: 1

G-Cyrillus
G-Cyrillus

Reputation: 105853

you can try force browser to refresh/recalculate layout of text playing with font-style: http://jsfiddle.net/H6rQ6/8730/

.ribbon-green {
    font-weight: bold ;
    font-size:12px;
    font-family:Sans-Serif;
    color: #111; 
     font-variant: small-caps;
    font-size:120%;    /* other rules */
}

edit, actually, it just have to do with font being too small to render smoothly.

regards

Upvotes: 1

Mooseman
Mooseman

Reputation: 18891

That's completely a browser bug. You can't really avoid it.

Upvotes: 0

Related Questions