我正在试着让"预约"按钮在这个网站https://templates.hibootstrap.com/arrola/default/index-2.html上工作.我有以下的css

.appointmentButton:before {
  content: '';
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  transform: scale(0);
  left: 0;
  right: 0;
  opacity: 0;
  z-index: -1;
  transition: all 0.5s;
}

.appointmentButton {
  padding: 10px 30px;
  color: white;
  text-align: center;
  position: relative;
  overflow: hidden;
  z-index: 0;
  text-transform: capitalize;
  transition: 0.5s;
  background-color: $black1;
  border: none;
  outline: none;
  text-decoration: none;
  &:hover:before {
    background-color: $greenColor;
    transform: scale(1);
    opacity: 1;
  }
}

和html元素: <a className={styles.appointmentButton} href="/appointment">Book an Apppointment</a>. 我在试着把按钮的背景 colored颜色 改成绿色.

推荐答案

约会按钮添加显示:内嵌块

.appointmentButton {
  padding: 10px 30px;
  color: white;
  text-align: center;
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-transform: capitalize;
  transition: 0.5s;
  border: none;
  outline: none;
  text-decoration: none;
  background-color: #191f30;
  display: inline-block;
}
  .appointmentButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
    transform: scale(0);
    opacity: 0;
    transition: all 0.5s;
    background-color: #72ae44;
    z-index: -1;
  }
  
 .appointmentButton:hover::before {
    width: 100%;
    height: 100%;
    transform: scale(1);
    opacity: 1;
  }
<a class="appointmentButton" href="/appointment">Book an Apppointment</a>

Css相关问答推荐

我控制的自定义单选按钮无法重新 Select

如何仅以WooCommerce单一产品页面为目标?

如何防止css边框缩小div?

如何使用Bootstrap将图像水平对齐,使其顶部和底部位于同一水平线上?

将数据从react组件发送到css文件

.NET 8 预览版 6 中不使用新项目模板提供 Blazor CSS 文件

媒体查询在生产中没有响应:React 18 应用程序

不明白为什么 div 不均匀并且不填满页面

为什么 :focus 会覆盖 :focus-visible ?

带有 flex 的 CSS 空 div 以扩展并保持纵横比

我怎样才能将我的按钮向上移动,因为文本是

Sass @use 排序

适合剩余高度

如何使半圆的边框淡出?

位置绝对混乱的 CSS Flexbox

如何保持包装的弹性项目与前一行元素的宽度相同?

在 IE9-10 中压缩 SVG 的背景大小

如何在渲染之前获取react 组件的大小(高度/宽度)?

使用 CSS 强制侧边栏高度 100%(带有粘性底部图像)?

CSS垂直对齐不适用于浮动