我有一個(藍色)div,我想放大(垂直)以覆蓋相同大小的多個div(其中12個)。用JavaScript調整div大小看起來不對
我採取的步驟是獲取div高度(帶浮點數),將值乘以12,然後將新大小應用於div。
生成的div不適合第12個div,並且無法理解爲什麼。 我認爲這與邊框/填充有關,但變量appHeadHeight
已包含這些度量(我已使用Chrome的Inspect工具對此進行了檢查)。
請看JSFiddle的整個代碼。歡迎任何建議。
var theAppointCode = "10071000116";
var theAppointLength = 12;
//get the blue cell height
var appHeadHeight = $("#"+theAppointCode)[0].getBoundingClientRect();
appHeadHeight = appHeadHeight.height;
//debug
alert("["+appHeadHeight+"] x ["+theAppointLength+"] = ["+(parseFloat(appHeadHeight)*parseFloat(theAppointLength))+"]");
//multiply the cell height by 12
document.getElementById(theAppointCode).style.height = (parseFloat(appHeadHeight)*parseFloat(theAppointLength))+"px";
的jsfiddle:https://jsfiddle.net/niandrei/vpgc73p2/1/
我需要新的div跨越12個格下來。用你的代碼跨越11和一點點。 – niandrei