當我嘗試在同一個類上放置不同的div時,onHover在鼠標懸停時無法正常工作。轉換多個對象在hover上搞砸
在我的jsfiddle你可以嘗試將鼠標懸停在綠色的部分:這是不會改變的curcus爲 「指針」
的jsfiddle:https://jsfiddle.net/bh6n7v3n/
HTML:
<div class="wrapper">
<div class="content">
<div class="inner_content"></div>
</div>
</div>
<div class="wrapper">
<div class="content"></div>
</div>
<div class="wrapper">
<div class="content"></div>
</div>
<div class="wrapper">
<div class="content"></div>
</div>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
CSS:
.wrapper{
position: absolute;
top: 50vh;
left: 50vw;
}
.content{
height: 200px;
width: 200px;
position: relative;
transform: rotateX(65deg) rotateY(0deg) rotateZ(-44deg);
-ms-transform: rotateX(65deg) rotateY(0deg) rotateZ(-44deg);
-webkit-transform: rotateX(65deg) rotateY(0deg) rotateZ(-44deg);
transform: rotateX(65deg) rotateY(0deg) rotateZ(-44deg);
transform-origin: 50% 50%;
-webkit-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
cursor: pointer;
background: rgba(255,0,0,0.2);
border: 2px solid black;
}
.inner_content{
height: 100px;
width: 100px;
background:green;
margin: 50px;
}
JS:
$(document).ready(function() {
var svgArray = $(".wrapper");
var startValue = 50;
var interval = 20;
var startTranslationValue = startValue - (Math.ceil((svgArray.length-1)/2)*interval);
for (var i = 0; i <= svgArray.length - 1; i++) {
svgArray.eq(i).css('transform', 'translateX(-50%) translateY(-' + startTranslationValue + '%)');
startTranslationValue += interval;
}
});
任何提示?
謝謝,這解決了這個問題! – JavascriptDeveloper