Slanted fonts get cut off with text-align:right

2k views Asked by At

If you have these big "slanted" fonts (not sure on the terminology), your opacity is less than 1, and you're using text-align:right, the end of the text will get cut off. I also found that in the OSX version of Safari, the end doesn't render even when the opacity is at 1. Anywhere else it seems to only be the case while opacity is < 1. This only seems to happen when aligning the text to the right.

I have recreated the problem in jsfiddle:

http://jsfiddle.net/qcr62eoa/

The code:

<head>
    <title>Test</title>
    <link href='http://fonts.googleapis.com/css?family=Playball' rel='stylesheet' type='text/css'>
    <style>
        .box {
            background-color: lightblue;
            width: 500px;
            font-family: 'Playball', cursive;
            text-align: right;
            padding-right:30px;
        }
        .box h1 {
            opacity: 0.5;
            font-size:48px;
            font-weight:400;
        }
    </style>
</head>
<body>
    <div class="box">
        <h1>Hello world</h1>
    </div>
</body>
1

There are 1 answers

4
Serge Inácio On

I don't know if you are looking for a workaround or an explanation, it is indeed weird and have no answer for that, but a workaround is available :). you could add some padding to the "box h1".

I tested it and it worked

<head>
    <title>Test</title>
    <link href='http://fonts.googleapis.com/css?family=Playball' rel='stylesheet' type='text/css'>
    <style>
        .box {
            background-color: lightblue;
            width: 500px;
            font-family: 'Playball', cursive;
            text-align: right;
            padding-right:30px;
        }
        .box h1 {
            opacity: 0.5;
            padding-right:10px;
            font-size:48px;
            font-weight:400;
        }
    </style>
</head>
<body>
    <div class="box">
        <h1>Hello world</h1>
    </div>
</body>

Hope this helped

cheers