Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コードは次のとおりです。
<div class="bar"> <div class="percentage" style="width:16%; height: 59px;">This is 66% wide div</div> </div>
ご覧のとおり、ここでは幅が 16 です....変数に基づいて変更できる方法が必要です。特定の値を返すphpクエリがあります。そして、幅はその値でなければなりません。どうやってやるの?
Javascriptでできます。たとえば、JQuery の場合:
$('.percentage').css({'width': x%, 'height': xpx});
または、PHP で実行できます。
<div class="percentage" style="width: <?php echo $width; ?>%; height: <?php echo $height; ?>px; ">This is 66% wide div</div>