【问题标题】:Add a border to hovered button CSS为悬停按钮 CSS 添加边框
【发布时间】:2020-07-02 11:10:30
【问题描述】:

嘿,当它悬停时,我想为我的按钮添加一个边框。在我的代码下面:

    button{
    background-color: #e876f5;
    font-size: 20px;
    color: white;
    border-radius: 3px;
  }

  button:focus{
    outline: none;
  }

  button:hover{
    background-color: white;
    border: 2px solid #e876f5;
    color:  #e876f5;
    cursor: pointer;
  }

我认为添加border: 2px solid #e876f5; 就足够了,但是当我悬停按钮时,没有边框。我该怎么办?

【问题讨论】:

  • 这里没有问题,你能给我们看看html吗?
  • 正如@Zdravko 所说的所有工作,唯一想到的是类上有一个覆盖。
  • 我的 HTML 中没有边框...<button type="button" style="width: 600px; height:40px; border:none;">现在可以使用

标签: css button hover border


【解决方案1】:

按钮首先添加边框,然后我们像这样悬停边框。

   button{
    background-color: #e876f5;
    font-size: 20px;
    color: white;
    border-radius: 3px;
    border:2px solid #e876f5;/* add normal button css */
  }

  button{
    background-color: #e876f5;
    font-size: 20px;
    color: white;
    border-radius: 3px;
    border:2px solid #e876f5;
  }

  button:focus{
    outline: none;
  }

  button:hover{
    background-color: white;
    border: 2px solid #e876f5;
    color:  #e876f5;
    cursor: pointer;
  }
<button>Button</button>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-21
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-19
    • 1970-01-01
    相关资源
    最近更新 更多