2017-04-14 11 views
0

CSSのプロパティを使用せずにdivのサイズを変更するには純粋なjavascriptコードを使用して高さまたは幅のサイズを変更するだけですか?divの縦または横のサイズを変更する

+2

すでに試してみましたか? – Mazz

+0

あなたが試したことのあるコード、または変更をどのように実装しようとしているのかを示します。 –

+0

答えて

0

style などで行うことができます。

getElementById('div_register').style.width='500px'; 
getElementById('div_register').style.height='500px'; 
+0

いいえあなたはあなたがそこに垂直または水平のサイズ変更 –

0

私は、最良の結果は以下のことが判明:

var div1 = document.getElementById("DivOne"); 
var dRect = div1.getBoundingClientRect(); 

var scrollBarWidth = 6; 
var w = window.innerWidth - 2*dRect.left - scrollBarWidth; 
var h = window.innerHeight - 2*dRect.top - scrollBarWidth; 
div1.style.width = w.toString() + "px"; 
div1.style.height = h.toString() + "px"; 

実施例:Single DIV sized to the document window

関連する問題