jqueryを使用して要素の幅を10remまで増やすにはどうすればよいですか?問題は、Jqueryは常に幅と高さをピクセル単位で返します。他の単位で高さ/幅を更新する必要があります。jqueryを使用してコンテナの幅を10分増やす
例について:JS Bin
var $c = $('#container');
console.log($c.width());
var c = document.getElementById('container');
// Q1. Why is it different from above one. This is 324 while earlier it was 320. See the output.
console.log(c.clientWidth);
// Q2. How to update the code to increase the width by 10rem.
$c.css({width: $c.width() + 10}); //It adds 10 pixels here.
console.log($c.width());
私の質問は、コード内のコメントです。
は、あなたの質問に同意しますが、私は、 'rem'ユニットは、**フォントのためだと思います-values/_ –
これは、デバイスサイズに合わせてページの内容を合わせることができるので、最近のem/rem単位はアプリでかなり使用されています。フォントサイズが変更されると、それに応じてその他の変更が行われます。 – sachinjain024