【发布时间】:2015-08-14 09:19:09
【问题描述】:
我需要在按钮旋转的同时旋转文本。由于某种原因,当我将鼠标悬停在按钮上时,文本当前正在消失。文本不应消失;它应该与我在这个项目中使用 Chrome 的按钮一起旋转。
http://codepen.io/matosmtz/pen/oXBaQE
HTML
<body>
<div class = "container">
<section class="3d-button">
<h2>Animated Button</h2>
<p class="btn_perspective">
<button class="btn btn-3d btn-3da">Submit</button>
</p>
</section>
</div>
</body>
CSS
html, body {
font-size: 100%;
padding: 0;
margin: 0;
height: 100%;
border: 0;
}
body {
font-family: Lekton;
background: rgb(245,245,245);
}
a {
color: #888;
text-decoration: none;
}
.container {
padding: 0;
margin: 0;
height: 100%;
background: #fff;
position: relative;
}
.container > section {
margin: 0 auto;
padding: 6em 3em;
text-align: center;
}
h2 {
margin: 20px;
text-align: center;
text-transform:uppercase;
letter-spacing: 1px;
font-size: 2em;
}
.btn {
border:none;
position: relative;
background: rgb(245,245,245);
padding: 15px 40px;
display: inline-block;
text-transform: uppercase;
margin: 15px 30px;
color: inherit;
letter-spacing: 2px;
font-size: .9em;
outline: none;
-webkit-transition: all 0.4s;
transition: all 0.4s;
cursor: pointer;
}
.btn:after {
content: "";
position: absolute;
z-index: -1;
-webkit-transition: all 0.4s;
transition: all 0.4s;
}
.btn_perspective {
-webkit-perspective: 800px;
perspective: 800px;
display: inline-block;
}
.btn-3d {
display: block;
background: #5cbcf6;
color: white;
outline: 1px solid transparent;
transform-style: preserve-3d;
}
.btn-3d:active {
background: #55b7f3;
}
.btn-3da:after {
width: 100%;
height: 42%;
left: 0;
top: -40%;
background: #53a6d7;
transform-origin: 0% 100%;
transform: rotateX(90deg);
}
.btn-3da:hover {
transform: rotateX(-45deg);
}
【问题讨论】:
-
你的 codepen 不工作
-
这很奇怪!我只是仔细检查了它,它工作正常。该按钮应在悬停时旋转并在悬停时返回其原始状态。
-
顺便说一下,代码被定制为只能在谷歌浏览器上运行。
-
您是否正在寻找这样的解决方案(适用于所有主要网络浏览器):infosoft.biz?
-
最终我希望它可以在所有浏览器上运行,但我省略了所有使其与其他浏览器兼容的代码,因为我目前正在使用 Chrome 进行原型设计。我将添加代码以使其立即与 Mozilla 一起使用。