I use the following code to change an rotateYitem when a user clicks a button.
The wrapper divuses the perspectiveCSS property to create a 3D effect.
The problem I encountered is only in Chrome , I am currently testing version 55.0.2883.87 m (64-bit version).
Basically, when a button is pressed and the inline CSS changes, the effect is perspectivenot applied. To apply this effect, the user needs to resize the browser window, or the code must be replaced with the same value perspectiveon the wrapper div.
The Firefox 50.1.0problem does not exist, and when the user spot button divhas the right perspective.
I'd like to know:
- If you have the same problem in your browser.
- If this is a known bug in Chrome or a problem with my code.
- If you know any work or fix.
Notes: - I have a restriction on the use of all inline CSS, since I cannot switch CSS classes.
var target = document.querySelector('#target');
document.querySelector('#btn').addEventListener('mousedown', function(event) {
target.style.transform = 'rotateZ(0deg) rotateY(45deg) rotateX(0deg) skewY(0deg) skewX(0deg) scaleX(1) scaleY(1)';
});
<button id="btn" type="button">Change rotation</button>
<div id="box-6o80mut6" style="position: absolute; top: 100px; left: 250px; perspective: 250px; z-index: 0;">
<div id="target" style="position: inherit; top: 0px; left: 0px; width: 304px; height: 204px; transform: rotateZ(0deg) rotateY(0deg) rotateX(0deg) skewY(0deg) skewX(0deg) scaleX(1) scaleY(1); border-radius: 10px; border-style: solid; border-width: 0px; background-color: rgb(82, 165, 255); border-color: rgb(0, 0, 0); opacity: 1; box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 0px 0px;">
</div>
</div>
Run codeHide result
source
share