2017-01-18 6 views
1

::afterセレクタの下のテキストからスタイルを削除する際に問題があり、インターネットから解決策を見つけることができませんでした。デザインは基本的に左側に向かって直線的な勾配です。:: afterセレクタでスタイリングを削除する

.txt { 
 
    background: -webkit-linear-gradient(left, #E27822,#E2224C); 
 
    -webkit-background-clip: text; 
 
    -webkit-text-fill-color: transparent; 
 
    font-weight: bold ; 
 
} 
 
.txt::after { 
 
    content: " - More Sample Text"; 
 
    background: none; 
 
    -webkit-background-clip: none !important; 
 
    -webkit-text-fill-color: none !important; 
 
    color: green; 
 
}
<span class="txt">Sample Text</span> 
 
<p>The "<b>More Sample Text</b>" should be coloured <span style="color: green;"><b>Green</b></span>.</p>

答えて

1

-webkit-text-fill-color色のみを受け付け、noneは、適切な色ではありません。

初期値(currentColor)にリセットしたかったようです。

.txt { 
 
    background: -webkit-linear-gradient(left, #E27822, #E2224C); 
 
    -webkit-background-clip: text; 
 
    -webkit-text-fill-color: transparent; 
 
    font-weight: bold; 
 
} 
 
.txt::after { 
 
    content: " - More Sample Text"; 
 
    color: green; 
 
    -webkit-text-fill-color: currentColor; 
 
}
<span class="txt">Sample Text</span> 
 
<p>The "<b>More Sample Text</b>" should be coloured <span style="color: green;"><b>Green</b></span>.</p>

古い背景のいくつかのマイナーな思い出は今でもおそらくアンチエイリアスに、テキストの周囲に表示されることがあります。これを防ぐために、白い背景を追加することができます。

.txt { 
 
    background: -webkit-linear-gradient(left, #E27822, #E2224C); 
 
    -webkit-background-clip: text; 
 
    -webkit-text-fill-color: transparent; 
 
    font-weight: bold; 
 
} 
 
.txt::after { 
 
    content: " - More Sample Text"; 
 
    -webkit-text-fill-color: green; 
 
    background: #ffffff; 
 
}
<span class="txt">Sample Text</span> 
 
<p>The "<b>More Sample Text</b>" should be coloured <span style="color: green;"><b>Green</b></span>.</p>

+0

'currentColor'の色は、現在のスタイルにオーバーレイされています。純粋なグリーンなので完全に取り除きたいです。 –

+0

何が重なっていますか?それは私のために純粋な緑です。 – Oriol

+0

グリーンテキストの周りに薄い枠があります。ボーダーは間違いなく古いスタイルです。 –

関連する問題