2017-12-02 7 views
2

ホバーアニメーションボタンを作成しようとしましたが、テキストをクリックしてもdivをクリックしても機能しません。アンカータグにdisplay:blockと書いてください。
以下は私のHTMLとCSSのコードですjsfiddleです。ボタンdivはクリックできませんテキストをクリックしても機能しませんでしたすべてを試してみました

HTML:

<div class="animation-button"> 
    <div class="raised hoverable"> 
    <div class="anim"></div><span><a href="index.php?option=com_content&view=about&Itemid=104">More About Us</a></span> 
    </div> 
</div> 

のCss:

.animation-button .raised { 
    position: relative; 
    margin: 1em; 
    font-weight: 100; 
    padding: 10px 19px; 
    text-align: center; 
    //min-width:14%; 
    /*width: 200px;*/ 
    /*border-radius: 5px;*/ 
    overflow: hidden; 
    position: relative; 
    z-index: 0; 
    cursor: pointer; 
    display: inline-block; 
} 
.animation-button .raised { 
    -moz-transition: all 0.1s; 
    -o-transition: all 0.1s; 
    -webkit-transition: all 0.1s; 
    transition: all 0.1s; 
    background: #849C8E; 
    box-shadow: 0px 1px 1px #849C8E; 
} 
.animation-button .raised:active { 
    background: #70897A; 
    box-shadow: 0px 1px 1px #70897A; 
    /* display: inline-block; */ 
} 

.animation-button .raised span a { 
    font-weight: 400; 
    font-size: 3vw; 
    color: #fff; 
    text-decoration: none; 
    display: block; 
} 

.animation-button span a:hover,#ankur span a:focus{ 
    color: #fff; 
    display: block; 
} 

.anim { 
    -moz-transform: translateY(-50%) translateX(-50%); 
    -ms-transform: translateY(-50%) translateX(-50%); 
    -webkit-transform: translateY(-50%) translateX(-50%); 
    transform: translateY(-50%) translateX(-50%); 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    z-index: -1; 
} 
.anim:before { 
    position: relative; 
    content: ''; 
    display: block; 
    margin-top: 100%; 
} 
.anim:after { 
    content: ''; 
    position: absolute; 
    top: 0; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    border-radius: 50%; 
} 

.hoverable:hover > .anim { 
    -moz-animation: anim-out 0.75s; 
    -webkit-animation: anim-out 0.75s; 
    animation: anim-out 0.75s; 
} 
.hoverable:hover > .anim:after { 
    -moz-animation: anim-out-pseudo 0.75s; 
    -webkit-animation: anim-out-pseudo 0.75s; 
    animation: anim-out-pseudo 0.75s; 
} 

@-webkit-keyframes anim-in { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@-moz-keyframes anim-in { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@-ms-keyframes anim-in { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@keyframes anim-in { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@-webkit-keyframes anim-in-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@-moz-keyframes anim-in-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@-ms-keyframes anim-in-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@keyframes anim-in-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@-webkit-keyframes anim-out { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@-moz-keyframes anim-out { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@-ms-keyframes anim-out { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@keyframes anim-out { 
    0% { 
    width: 0%; 
    } 
    100% { 
    width: 100%; 
    } 
} 
@-webkit-keyframes anim-out-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@-moz-keyframes anim-out-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@-ms-keyframes anim-out-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 
@keyframes anim-out-pseudo { 
    0% { 
    background: rgba(0, 0, 0, 0.25); 
    } 
    100% { 
    background: transparent; 
    } 
} 

jsfiddle:https://jsfiddle.net/a2zgk/yL8ngrx5/1/

+2

whats not working ?? –

+0

誰かがdivをクリックしても、通常のリンクのようにクリックしたいと思っています。 –

+0

問題は、テキストの外側をクリックすることです(しかし、ボタンの内側にある)が新しいページを開くことはありません。 –

答えて

2

リンクは全域をカバーするように、代わりにbuttonaタグにパディングを追加します。このようなボタン:

.animation-button .raised { 
 
    position: relative; 
 
    margin: 1em; 
 
    font-weight: 100; 
 
    text-align: center; 
 
    //min-width:14%; 
 
    /*width: 200px;*/ 
 
    /*border-radius: 5px;*/ 
 
    overflow: hidden; 
 
    position: relative; 
 
    z-index: 0; 
 
    cursor: pointer; 
 
    display: inline-block; 
 
} 
 

 
.animation-button .raised { 
 
    -moz-transition: all 0.1s; 
 
    -o-transition: all 0.1s; 
 
    -webkit-transition: all 0.1s; 
 
    transition: all 0.1s; 
 
    background: #849C8E; 
 
    box-shadow: 0px 1px 1px #849C8E; 
 
} 
 

 
.animation-button .raised:active { 
 
    background: #70897A; 
 
    box-shadow: 0px 1px 1px #70897A; 
 
    /* display: inline-block; */ 
 
} 
 

 
.animation-button .raised span a { 
 
    font-weight: 400; 
 
    font-size: 3vw; 
 
    color: #fff; 
 
    text-decoration: none; 
 
    display: block; 
 
    padding: 10px 19px; 
 
} 
 

 
.animation-button span a:hover, 
 
#ankur span a:focus { 
 
    color: #fff; 
 
    display: block; 
 
} 
 

 
.anim { 
 
    -moz-transform: translateY(-50%) translateX(-50%); 
 
    -ms-transform: translateY(-50%) translateX(-50%); 
 
    -webkit-transform: translateY(-50%) translateX(-50%); 
 
    transform: translateY(-50%) translateX(-50%); 
 
    position: absolute; 
 
    top: 50%; 
 
    left: 50%; 
 
    z-index: -1; 
 
} 
 

 
.anim:before { 
 
    position: relative; 
 
    content: ''; 
 
    display: block; 
 
    margin-top: 100%; 
 
} 
 

 
.anim:after { 
 
    content: ''; 
 
    position: absolute; 
 
    top: 0; 
 
    bottom: 0; 
 
    left: 0; 
 
    right: 0; 
 
    border-radius: 50%; 
 
} 
 

 
.hoverable:hover>.anim { 
 
    -moz-animation: anim-out 0.75s; 
 
    -webkit-animation: anim-out 0.75s; 
 
    animation: anim-out 0.75s; 
 
} 
 

 
.hoverable:hover>.anim:after { 
 
    -moz-animation: anim-out-pseudo 0.75s; 
 
    -webkit-animation: anim-out-pseudo 0.75s; 
 
    animation: anim-out-pseudo 0.75s; 
 
} 
 

 
@-webkit-keyframes anim-in { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@-moz-keyframes anim-in { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@-ms-keyframes anim-in { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@keyframes anim-in { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@-webkit-keyframes anim-in-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@-moz-keyframes anim-in-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@-ms-keyframes anim-in-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@keyframes anim-in-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@-webkit-keyframes anim-out { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@-moz-keyframes anim-out { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@-ms-keyframes anim-out { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@keyframes anim-out { 
 
    0% { 
 
    width: 0%; 
 
    } 
 
    100% { 
 
    width: 100%; 
 
    } 
 
} 
 

 
@-webkit-keyframes anim-out-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@-moz-keyframes anim-out-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@-ms-keyframes anim-out-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
} 
 

 
@keyframes anim-out-pseudo { 
 
    0% { 
 
    background: rgba(0, 0, 0, 0.25); 
 
    } 
 
    100% { 
 
    background: transparent; 
 
    } 
 
}
<div class="animation-button"> 
 
    <div class="raised hoverable"> 
 
    <div class="anim"></div><span><a href="index.php?option=com_content&view=about&Itemid=104">More About Us</a></span> 
 
    </div> 
 
</div>

+0

Thnaks manだから私は次回はこれを覚えていません:) –

関連する問題