【问题标题】:How to remove black border from this round icon?如何从此圆形图标中删除黑色边框?
【发布时间】:2019-08-05 14:41:04
【问题描述】:

鼠标悬停将背景更改为黑色,但我想删除黑色边框,并将图标变为圆形。

.our-activity-div {
  padding: 20px;
  text-align: center;
}

.our-activity-inner {
  width: 33%;
  box-sizing: border-box;
  display: inline-block;
}

.fundraising {
  max-width: 75%;
  min-height: 220px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
  border-radius: 10px;
  margin: 0 auto;
  line-height: 0px;
  padding: 30px 35px;
  box-sizing: border-box;
}

.fundraise-hr {
  width: 25%;
  border-color: #000;
}

.fundraise-padding {
  text-align: left;
  padding-top: 20px;
}

.fundraising-parag {
  padding: 10px 5px;
  line-height: 1.5em;
}

.symbol0 {
  color: #000;
  font-size: 100px;
  position: relative;
  top: -28px;
  border-radius: 50%;
}

.fundraising:hover .fundraise-padding {
  color: #01d262;
}

.fundraising:hover .fundraise-hr {
  border-color: #01d262;
}

.fundraising:hover .symbol0 {
  background-color: #000;
  color: #01d262;
}
<div class="our-activity-div">
  <div class="our-activity-inner">
    <div class="fundraising">
      <span class="symbol0">&#9775;</span>
      <h2 class="fundraise-padding ">Fundraising</h2>
      <hr class="fundraise-hr "></hr>
      <p class="fundraising-parag">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
      </p>
    </div>
  </div>
</div>

【问题讨论】:

  • 你能把你的代码全部包含进来吗?
  • 悬停时没有任何反应...
  • 你能添加codepen吗?
  • 找不到任何悬停代码。请添加正确的代码。谢谢
  • 发布了完整的编码。我需要 .symbol0 的背景颜色为黑色,但不需要将边框显示为黑色。

标签: html css


【解决方案1】:

从 .fundraising:hover .symbol0 中移除 css 中的背景色

并在:hover 上使用pseudo element 作为:after 并设置演示背景

.our-activity-div {
  padding: 20px;
  text-align: center;
}

.our-activity-inner {
  width: 33%;
  box-sizing: border-box;
  display: inline-block;
}

.fundraising {
  max-width: 75%;
  min-height: 220px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
  border-radius: 10px;
  margin: 0 auto;
  line-height: 0px;
  padding: 30px 35px;
  box-sizing: border-box;
}

.fundraise-hr {
  width: 25%;
  border-color: #000;
}

.fundraise-padding {
  text-align: left;
  padding-top: 20px;
}

.fundraising-parag {
  padding: 10px 5px;
  line-height: 1.5em;
}

.symbol0 {
  color: #000;
  font-size: 100px;
  position: relative;
  top: -28px;
  border-radius: 50%;
}

.fundraising:hover .fundraise-padding {
  color: #01d262;
}

.fundraising:hover .fundraise-hr {
  border-color: #01d262;
}

.fundraising:hover .symbol0 {
  color: #01d262;
}

.fundraising:hover .symbol0:after {
  content: '';
  background-color: #000;
  position: absolute;
  width: 80%;
  height: 50%;
  top: 24px;
  z-index: -1;
  left: 9px;
  border-radius: 50%;
}
<div class="our-activity-div">
  <div class="our-activity-inner">
    <div class="fundraising">
      <span class="symbol0">&#9775;</span>
      <h2 class="fundraise-padding ">Fundraising</h2>
      <hr class="fundraise-hr "></hr>
      <p class="fundraising-parag">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
      </p>
    </div>
  </div>
</div>

【讨论】:

  • 告诉我更多帮助
【解决方案2】:

尝试关注 css

span.symbol0:hover {
    background: none !important;
}

【讨论】:

  • 不需要使用重要的:只在css中从.fundraising:hover .symbol0中删除background-color
  • 请解释为什么你声称你的代码回答了这个问题。
【解决方案3】:

删除下面代码中的背景色:

.fundraising:hover .symbol0 {
  background-color: #000;
  color: #01d262;
}

【讨论】:

    猜你喜欢
    • 2013-04-01
    • 1970-01-01
    • 2019-11-17
    • 2020-12-27
    • 2021-04-03
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    相关资源
    最近更新 更多