javascript - Can I use calc() when setting attributes with setAttribute?
PHP中文网
PHP中文网 2017-05-19 10:37:19
0
1
595

Can I use calc() when setting attributes with setAttribute?

<svg id='svg' xmlns="http://www.w3.org/2000/svg" width="1122" height="800"></svg>
<script>
    document.getElementById('svg').setAttribute('height','calc(100vw * 0.5)')
</script>

This is set as a string.

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
某草草

To set the style, you can pass:

document.getElementById('svg').style.height = 'calc(100vw * 0.5)';
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template