文本不随按钮旋转

时间:2015-06-01 01:53:21

标签: html css

我需要帮助在按钮旋转的同时旋转文本。出于某种原因,当我将鼠标悬停在按钮上时,文本正在消失。案文不应该消失;它应该使用按钮来旋转,使用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);
}

2 个答案:

答案 0 :(得分:0)

您可以查看这个纯CSS3解决方案(适用于所有主要的网络浏览器:DEMO):

/*ROTATE*/
.divRotate 
{
    -moz-transition     : all 0.8s;
    -webkit-transition  : all 0.8s;
    -o-transition       : all 0.8s;
    transition          : all 0.8s;
}
.divRotate:hover 
{

    -moz-transform      : rotate(360deg);
    -webkit-transform   : rotate(360deg);
    -o-transform        : rotate(360deg);
    transform           : rotate(360deg);
}

将div元素添加到HTML并引用class = 'divRotate'

希望这可能会有所帮助。最好的问候,

答案 1 :(得分:0)

这是更新的代码集:http://codepen.io/anon/pen/KpaGYd

在按钮中添加了以下代码:

{{1}}