当我单击按钮时,我想将div高度增加25%,因此我希望能够获得最后一个div高度值(以%表示),并简单地添加25。
是否存在一个javaScript方法,该方法将返回“ 80%”(即CSS中定义的高度),而不返回计算所得元素的px值为80%?
<div class="container">
</div>
html, body {
margin: 0;
height: 100%;
width: 100%;
}
.container {
height: 80%;
background: #eee;
}
let container = document.querySelector('.container');
console.log(container.style.height); //Empty
console.log(container.clientHeight); //Calculated px value at 80%
//I am looking for a method/way to return '80%'
答案 0 :(得分:0)
难道不能只获取元素的高度并将其除以其父元素的高度乘以100吗?
答案 1 :(得分:0)
SELECT B.size, B.bidprice
FROM `nyt-adtech-prd.dfp_data.dfp_log_network_requests`,
UNNEST(ad_request_custom_targeting) A,
UNNEST(A.iom) B
WHERE DATE(_PARTITIONTIME) = "2019-05-03"
LIMIT 1000
假设大多数人不会设置分数%值,那么将元素的高度除以包含元素的高度就可以得到所需的值。