是否可以在 Javascript 中的 css3 转换期间获得目标(最终)计算出的 css 属性值?
我找到了这个答案: Is it possible to get the target css property value during a css3 transition in Javascript?
所以,我可以把它作为
document.getElementById('transition_div').style.width
Run Code Online (Sandbox Code Playgroud)
但是这仅在 css 中指定了目标 css 属性时才有效。我需要获取动态计算的目标属性值 - 未在 CSS 中指定。
HTML:
<table>
<tr>
<td id="cell-1">CELL 1</td>
<td id="cell-2">CELL 2</td>
<td id="cell-3">CELL 3 some text</td>
<tr>
<table>
Run Code Online (Sandbox Code Playgroud)
CSS
td {
transition: all 3s linear;
}
Run Code Online (Sandbox Code Playgroud)
JS
setTimeout(function() { //let's browser draw initial state
document.getElementById("cell-1").style["min-width"] = "300px"; //resize one of cells
setTimeout(function() {
//NOW, a second later, …Run Code Online (Sandbox Code Playgroud)