问题描述
我有2个元素,每次单击我的按钮时,两个元素都应该旋转Y(180deg),但是我现在拥有的代码仅旋转第一个。如何实现我所有元素的变形? (香草JS)
.question {
width:100%;
height:100%;
transition:transform 0.5s;
transform-style:preserve-3d;
}
.sceneQ {
width:600px;
height:150px;
}
.questionTransform {
transform:rotateY(190deg)
}
.face {
text-align:center;
backface-visibility:hidden;
}
.back {
transform: rotateY(180deg);
}
<button id="hintbtn" onclick="doTransform()">Do Transform</button>
<div id="sceneQ1" class="sceneQ">
<div class="question" id="Q1">
<div class="face front">
<p>Where does skateboarding originate from?</p>
</div>
<div class="face back">
<p>Someplace in America...</p>
</div>
</div> </div>
<div id="sceneQ2" class="sceneQ">
<div class="question" id="Q2">
<div class="face front">
<p>In what decade were the first kind of skateboards created?</p>
</div>
<div class="face back">
<p>After the 2nd World War...</p>
</div>
</div> </div>
function doTransform() {
const element = document.querySelector('.sceneQ .question')
element.classList.toggle('questionTransform')
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)