【问题标题】:How to create a card hover background color如何创建卡片悬停背景颜色
【发布时间】:2019-07-06 15:47:04
【问题描述】:

我正在尝试设置卡片布局,当用户将鼠标悬停在卡片上时卡片会改变背景颜色。喜欢本页的卡片:https://texasdeafed.org/students/programs

我尝试在标题中添加悬停信息,我有阴影:

.card:hover {
    background-color: #fffff
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}

示例:

.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  transition: 0.3s;
  width: 50%;
  background-color: #DCE1E0;
}

.card:hover {
  background-color: #fffff;
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}

.container {
  padding: 2px 5px;
}
<div class="card">
  <br />
  <center>
    <h1>Family Weekend
      <br />
      <br />Retreat</h1>
  </center>
  <br />

  <img src="/cms/lib6/TX01923182/Centricity/Domain/180/Shelly_Parent_Liaison_ca    rdflipped.jpg" alt="Woman reading Parent Liaison card by     texasdeafed.org" style="width:100%">

  <div class="container">
    <br />
    <p>
      A special weekend in Austin for families with deaf and hard of hearing children hosted by the Educational Resource Center on Deafness at Texas School for the Deaf </p>
    <br />
    <br />
    <br />
  </div>
</div>

我希望悬停颜色变为白色,但根本没有变化。

【问题讨论】:

  • 您的白色颜色代码不正确。试试 #fff 或 #ffffff(3 或 6 个字符)
  • 谢谢,我试过你的建议,但没有任何改变。
  • 看到这个fiddle

标签: css hover


【解决方案1】:

您所做的一切都很好,您的 css 唯一的错误是十六进制代码。 在您尝试使用#fffff - 5 次字母 f 赋予白色的地方,它需要 6 次, 检查我的回复! 祝你好运。

.card {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  transition: 0.3s;
  width: 50%;
  background-color: #DCE1E0;
}

.card:hover {
  background-color: #ffffff;
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}

.container {
  padding: 2px 5px;
}
<div class="card">
  <br />
  <center>
    <h1>Family Weekend
      <br />
      <br />Retreat</h1>
  </center>
  <br />

  <img src="/cms/lib6/TX01923182/Centricity/Domain/180/Shelly_Parent_Liaison_ca    rdflipped.jpg" alt="Woman reading Parent Liaison card by     texasdeafed.org" style="width:100%">

  <div class="container">
    <br />
    <p>
      A special weekend in Austin for families with deaf and hard of hearing children hosted by the Educational Resource Center on Deafness at Texas School for the Deaf </p>
    <br />
    <br />
    <br />
  </div>
</div>

【讨论】:

    【解决方案2】:

    将背景颜色设置为#ffffff

    【讨论】:

    • 谢谢。 Ori Drori 提出了同样的建议。现在可以了。谢谢你们!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    • 2013-06-26
    • 2010-10-15
    • 2012-03-05
    • 1970-01-01
    相关资源
    最近更新 更多