2016-02-22 1 views
2

Моя волновая волна CSS не работает должным образом. Это просто видно как пузырь в центре, когда я нажимаю на кнопку. Пожалуйста, помогите найти, где я делаю ошибку. Я не очень хорошо знаком с анимацией CSS. я хотел бы сделать это, используя только CSS.Эффект соприкосновения с CSS, не работает должным образом

.ripple-con, 
 
.button { 
 
    display: inline-block; 
 
    position: relative; 
 
    overflow: hidden; 
 
} 
 

 
.button::after, 
 
.ripple { 
 
    content: ' '; 
 
    background: rgba(0, 0, 0, 0.3); 
 
    position: absolute; 
 
    top: 50%; 
 
    left: 50%; 
 
    width: 0; 
 
    height: 0; 
 
    display: inline-block; 
 
    border-radius: 100%; 
 
} 
 

 
.button:active::after, 
 
.ripple:active, 
 
.button:active+.ripple { 
 
    animation: ripple 2s; 
 
} 
 

 
@keyframes ripple { 
 
    to { 
 
    opacity: 0; 
 
    margin: -250px; 
 
    width: 500px; 
 
    height: 500px; 
 
    } 
 
} 
 

 
.button { 
 
    line-height: 39px; 
 
    border: 0; 
 
    height: 42px; 
 
    box-sizing: border-box; 
 
    padding: 0 20px; 
 
    background: #888; 
 
    border-radius: 5px; 
 
    cursor: default; 
 
    vertical-align: top; 
 
} 
 

 
html { 
 
    text-align: center 
 
} 
 

 
body { 
 
    display: inline-block 
 
}
<div class="ripple-con"> 
 
    <input class="button" type="submit" value="Submit Button : Button"> 
 
    <span class="ripple"></span> 
 
</div> 
 

 
<div class="ripple-con"> 
 
    <input class="button" type="button" value="Input Button : Button"> 
 
    <span class="ripple"></span> 
 
</div> 
 

 
<div class="button">Div : Button</div> 
 

 
<button class="button">Button : Button</button>

ответ

4

Просто поместите animation: ripple внутри .button::after, .ripple определения стиля и место animation: none, где идет активный следующим

.ripple-con, 
 
.button { 
 
    display: inline-block; 
 
    position: relative; 
 
    overflow: hidden; 
 
} 
 

 
.button::after, 
 
.ripple { 
 
    content: ' '; 
 
    background: rgba(0, 0, 0, 0.3); 
 
    position: absolute; 
 
    top: 50%; 
 
    left: 50%; 
 
    width: 0; 
 
    height: 0; 
 
    display: inline-block; 
 
    border-radius: 100%; 
 
    animation: ripple 2s; 
 
} 
 

 
.button:active::after, 
 
.ripple:active, 
 
.button:active + .ripple { 
 
    animation: none; 
 
} 
 

 
@keyframes ripple { 
 
    to { 
 
    opacity: 0; 
 
    margin: -250px; 
 
    width: 500px; 
 
    height: 500px; 
 
    } 
 
} 
 

 
.button { 
 
    line-height: 39px; 
 
    border: 0; 
 
    height: 42px; 
 
    box-sizing: border-box; 
 
    padding: 0 20px; 
 
    background: #888; 
 
    border-radius: 5px; 
 
    cursor: default; 
 
    vertical-align: top; 
 
} 
 

 
html { 
 
    text-align: center 
 
} 
 

 
body { 
 
    display: inline-block 
 
}
<div class="ripple-con"> 
 
    <input class="button" type="submit" value="Submit Button : Button"> 
 
    <span class="ripple"></span> 
 
</div> 
 

 
<div class="ripple-con"> 
 
    <input class="button" type="button" value="Input Button : Button"> 
 
    <span class="ripple"></span> 
 
</div> 
 

 
<div class="button">Div : Button</div> 
 

 
<button class="button">Button : Button</button>

Вот fiddle