x1c 0d1x的数据你好,我正在学习CSS,想知道如何实现上面的样式。它被称为什么样的效果/样式?我以前从来没有实现过这样的东西,所以我甚至不知道从哪里开始。
ogsagwnx1#
我已经实现了一些东西。这是非常相似的设计,你已经分享。
.button { position: relative; padding: 20px 25px; background: #0977d0; color: #fff; border: 0; font-size: 14px; font-weight: 700; border-radius: 5px; overflow: hidden; cursor: pointer; } .button:before { width: 20px; height: 20px; content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 0; background: rgba(255, 255, 255, 0.3); border-radius: 50%; transition: all 0.4s ease-in-out; opacity: 0; } .button span { position: relative; z-index: 1; } .button:hover::before { width: 70px; height: 70px; opacity: 1; }
个字符
7kjnsjlb2#
<button>Click Me!</button>
字符串和Css代码
<style type="text/css"> @keyframes gradient { 0% { background: radial-gradient(circle at center, rgba( 255, 125 , 125, 0 ) 0%, #fff 0%, #fff 100%); } 25% { background: radial-gradient(circle at center, rgba( 255, 125, 125, 0.3 ) 24%, #fff 25%, #fff 100%); } 50% { background: radial-gradient(circle at center, rgba( 255, 125, 125, 0.5 ) 49%, #fff 50%, #fff 100%); } 75% { background: radial-gradient(circle at center, rgba( 255, 125, 125, 0.8 ) 74%, #fff 75%, #fff 100%); } 100% { color: #fff; background: radial-gradient(circle at center, #f88 99%, #fff 100%, #fff 100%); } } body { background: #68d; } button { margin-left: calc( 50vw - 175px ); margin-top: calc( 50vh - 30px ); width: 350px; height: 60px; border: none; border-radius: 5px; background: #fff; font-weight: bold; font-size: 1.1em; color: #666; box-shadow: 0 6px 6px #06f; outline: none; } button:active { /* set time duration to your needs */ animation: gradient 100ms; background: #f88; color: #fff; box-shadow: none; } </style>
型
qlzsbp2j3#
也可以使用JS和CSS类实现
<div class='button'></div>
字符串
CSS
.button { width: 220px; height: 70px; background-color:blue; overflow: hidden; position: relative; cursor: pointer; transition: 0.3s; } .ripple { border-radius: 50%; background-color: rgba(255, 255, 255, 0.5); position: absolute; transform: scale(0); animation: ripple 0.6s linear; pointer-events: none; } @keyframes ripple { to { transform: scale(3.5); opacity: 0; } }
JS
function buttonClick() { var buttons = document.querySelectorAll('.button') Array.prototype.forEach.call(buttons, function(button) { button.addEventListener('click', createRipple) }) } function createRipple(element) { var circle = document.createElement('div') this.appendChild(circle) var dimensions = Math.max(this.clientWidth, this.clientHeight) circle.style.width = circle.style.height = dimensions + 'px' circle.style.left = element.clientX - this.offsetLeft - dimensions / 2 + 'px' circle.style.top = element.clientY - this.offsetTop - dimensions / 2 + 'px' circle.classList.add('ripple') circle.addEventListener('animationend', () => { circle.remove() }) }
3条答案
按热度按时间ogsagwnx1#
我已经实现了一些东西。这是非常相似的设计,你已经分享。
个字符
7kjnsjlb2#
字符串
和Css代码
型
qlzsbp2j3#
也可以使用JS和CSS类实现
字符串
CSS
型
JS
型