我制作了代码,这是一个带按钮的气泡菜单。它在Chrome上完美运行但在mozilla上运行错误。 你可以看到并试一试
$(".roundedBallOuter").click(function(e) {
$(this).toggleClass("clicked");
});
body {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.roundedBallOuter {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.roundedBall {
width: 200px;
height: 200px;
background: #ccc;
border-radius: 100%;
position: relative;
transition: all 0.3s ease;
cursor: pointer;
}
.roundedBall:hover {
transform: scale(1.1);
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
-moz-transform: scale(1.1);
box-shadow: 0 0 10px #555;
transition: all 0.3s ease;
}
.subBall {
width: 50px;
height: 50px;
background: #0077ab;
border-radius: 100%;
position: absolute;
transition: all 0.5s ease;
z-index: -1;
}
.roundedBallOuter.clicked .subBall.linkedIn {
transform: translate(-10em);
-webkit-transform: translate(-10em);
-moz-transform: translate(-10em);
-ms-transform: translate(-10em);
transition: all 0.5s ease;
}
.roundedBallOuter.clicked .subBall.facebook {
transform: rotate(45deg) translate(-10em) rotate(-45deg);
-webkit-transform: rotate(45deg) translate(-10em) rotate(-45deg);
-ms-transform: rotate(45deg) translate(-10em) rotate(-45deg);
-moz-transform: rotate(45deg) translate(-10em) rotate(-45deg);
transition: all 0.5s ease;
}
.roundedBallOuter.clicked .subBall.twitter {
transform: rotate(90deg) translate(-10em) rotate(-90deg);
-webkit-transform: rotate(90deg) translate(-10em) rotate(-90deg);
-moz-transform: rotate(90deg) translate(-10em) rotate(-90deg);
-ms-transform: rotate(90deg) translate(-10em) rotate(-90deg);
transition: all 0.5s ease;
}
.more {
font-size: 20px;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.more>span {
color: #0077ab;
display: block;
font-style: italic;
font-size: 25px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="roundedBallOuter">
<div class="roundedBall">
<span class="more"><span>Click</span> for more information</span>
</div>
<div class="linkedIn subBall"></div>
<div class="facebook subBall"></div>
<div class="twitter subBall"></div>
</div>
你能帮我解决一下这个错误吗? 提前致谢
答案 0 :(得分:0)
您将小球定位为absolute
,但是您没有给出绝对位置。
您可以通过将该位置设置为原始镀铬的确切位置(即top: 75px; left: 75px;
)
以下是修复:
$(".roundedBallOuter").click(function(e) {
$(this).toggleClass("clicked");
});
&#13;
body {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.roundedBallOuter {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.roundedBall {
width: 200px;
height: 200px;
background: #ccc;
border-radius: 100%;
position: relative;
transition: all 0.3s ease;
cursor: pointer;
}
.roundedBall:hover {
transform: scale(1.1);
-webkit-transform: scale(1.1);
-ms-transform: scale(1.1);
-moz-transform: scale(1.1);
box-shadow: 0 0 10px #555;
transition: all 0.3s ease;
}
.subBall {
width: 50px;
height: 50px;
background: #0077ab;
border-radius: 100%;
position: absolute;
transition: all 0.5s ease;
z-index: -1;
top: 75px;
left: 75px;
}
.roundedBallOuter.clicked .subBall.linkedIn {
transform: translate(-10em);
-webkit-transform: translate(-10em);
-moz-transform: translate(-10em);
-ms-transform: translate(-10em);
transition: all 0.5s ease;
}
.roundedBallOuter.clicked .subBall.facebook {
transform: rotate(45deg) translate(-10em) rotate(-45deg);
-webkit-transform: rotate(45deg) translate(-10em) rotate(-45deg);
-ms-transform: rotate(45deg) translate(-10em) rotate(-45deg);
-moz-transform: rotate(45deg) translate(-10em) rotate(-45deg);
transition: all 0.5s ease;
}
.roundedBallOuter.clicked .subBall.twitter {
transform: rotate(90deg) translate(-10em) rotate(-90deg);
-webkit-transform: rotate(90deg) translate(-10em) rotate(-90deg);
-moz-transform: rotate(90deg) translate(-10em) rotate(-90deg);
-ms-transform: rotate(90deg) translate(-10em) rotate(-90deg);
transition: all 0.5s ease;
}
.more {
font-size: 20px;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.more>span {
color: #0077ab;
display: block;
font-style: italic;
font-size: 25px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="roundedBallOuter">
<div class="roundedBall">
<span class="more"><span>Click</span> for more information</span>
</div>
<div class="linkedIn subBall"></div>
<div class="facebook subBall"></div>
<div class="twitter subBall"></div>
</div>
&#13;
答案 1 :(得分:0)
我这样做了(说实话我并不真正同意像素计算),但它做了它必须做的事情。谢谢大家!
#restOfThings .subBall {
position: absolute;
transition: all 0.5s ease;
z-index: 0;
left: -webkit-calc(50% - 25px);
left: -moz-calc(50% - 25px);
left: calc(50% - 25px);
top: -webkit-calc(50% - 25px);
top: -moz-calc(50% - 25px);
top: calc(50% - 25px);
}