18px 未満のすべてのフォント サイズをターゲットにして、より低いfont-weight
値を適用できる簡単な方法が必要です。
これは現在 CSS で可能ですか?
インライン スタイルや CSS スタイルについて言及していないので、ここに 1 つの解決策があります。エレガントではありません.. :)インラインスタイルの場合(インラインスタイルを使用する標準的な方法ではありませんが)
<p style="font-size:11px;">11</p>
<p style="font-size:12px;">12</p>
<p style="font-size:13px;">13</p>
<p style="font-size:14px;">14</p>
<p style="font-size:15px;">15</p>
<p style="font-size:16px;">16</p>
[style*=font-size\:11px],[style*=font-size\:12px],[style*=font-size\:13px],[style*=font-size\:14px],[style*=font-size\:15px]
{
color: blue;
font-weight:normal !important;
}
p
{
font-weight:bold;
}
css スタイルについては、数式を定量化または適用できる css で知っている限り、jquery または javascript を使用する必要があります。 http://jsfiddle.net/J3x4j/11/
$('p').each(function(){
//replace px or em or whatever unit
var fontsize = parseInt($(this).css('font-size').replace('px'));
if(fontsize < 18)
{
$(this).css('font-weight','normal');
}
});
基本的に、18px 未満のすべてのテキストを太字にしないでください。基本的に、18px を超えるテキストはすべて太字です。最も簡単な (最も理解しやすい) 方法は、異なるクラスを作成することです。例えば:
.twentypnt{
font-size:20px;
font-weight:bold;
}
.twelvepnt{
font-size:12px;
}
または、javascript ステートメントを作成することもできます。
function checkWeight(){
if(parseInt(document.getElementById('thing').style.fontsize) > 18)
document.getElementById('thing').style.fontweight = "bold";
}
それはうまくいくと思いますが、テキストのセットごとにそれを実行する必要があります。