Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getStyle(dom, key) {
- let style
- if (window.getComputedStyle) {
- style = window.getComputedStyle(dom, null) // 非IE
- } else {
- style = dom.currentStyle // IE
- }
- return style[key]
- }
- function isSupportCalc() {
- let oDiv = document.createElement("div");
- oDiv.style.width = 'calc((100vw / 750) * 100)'
- document.body.appendChild(oDiv)
- let width = getStyle(oDiv, 'width')
- oDiv.remove()
- let diff = 0.5
- width = parseFloat(width)
- let calcWidth = window.screen.availWidth / 750 * 100
- return width && Math.abs(calcWidth - width) < diff
- }
Add Comment
Please, Sign In to add comment