html - 我想要一些按钮上的滑出效果

标签 html css animation

我有四个按钮,每当我点击某个按钮时,它应该将背景颜色滑出到特定按钮

.active{
color:white;
background-color:blue;

}
button{
background-color:dodgerblue;
color:white;
box-shadow:none;
border:1px solid transparent;
}
<html>
<head>
</head>
<body>
  <button  class="active">Avon</utton>
  <button>Biseri</button>
  <button>Poliadal</button>
  <button>Aqualitical</button>
</body>
</html>

最佳答案

您可以使用 -webkit-transition

function myFunction(e) {
  if (document.querySelector('#navList a.active') !== null) {
    document.querySelector('#navList a.active').classList.remove('active');
  }
  e.target.className = "active";
}
.active {
  color: pink;
  background-color: beige;
 box-shadow: inset 0 -3.25em 0 0 beige;
}

button {
  background-color: aqua;
  color: white;
  border: 1px solid transparent;
  box-shadow: inset 0 0 0 0 #D80286;
  -webkit-transition: ease-out 0.4s;
  -moz-transition: ease-out 0.4s;
  transition: ease-out 0.4s;
  padding: 18px 36px;
}
<html>

<head>
</head>

<body>
  <div onclick="myFunction(event)">
    <button>Avon</button>
    <button>Biseri</button>
    <button>Poliadal</button>
    <button>Aqualitical</button>
  </div>
</body>

</html>

关于html - 我想要一些按钮上的滑出效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57430336/

相关文章:

javascript - 如何像在移动Chrome中的YouTube上一样激活全屏

html - Accordion 式显示内的粘性标题

html - 两个 div 左右浮动发生了什么

html - 多个关键帧动画在 safari 中不起作用

javascript - 获取元素坐标

javascript - Selectize.js "Uncaught TypeError: Cannot read property ' extend' of undefined"

html - 如何使用 CSS 设置响应式背景图像

jquery - 如何在有人单击表单后向表单添加样式,并在有人点击离开时删除此样式

html - Bootstrap : How to align a paragraph next to the center of an img?

python - Matplotlib FuncAnimation 慢