【问题标题】:CSS3 hover state background image sizeCSS3 悬停状态背景图片大小
【发布时间】:2014-04-12 20:47:43
【问题描述】:

因此,当我将鼠标悬停在新网站上的按钮上时,会出现箭头的背景图像。效果很好。但是,在 Chrome 中(还没有在其他浏览器上测试过),第一个显示为一个大箭头,第二个之后它变成了正确的大小。

这是我的网站:

http://stilld.nl/nieuw/

这是我正在使用的代码:

HTML:

<a class="btn1" href="contact/"><h4>
            PLAN UW PROJECT
</h4></a>

CSS:

  .item a {
    text-decoration: none;
}

.item h4 {
    position: absolute;
    max-width: 200px;
    width: 100%;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    line-height: 43px;
    font-size: 16px;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 28px;
    padding-right: 28px;
    margin-top: 0px;
    bottom: 180px;
    left: 8.5%;
    color: white;
    border-radius: 6px;
    letter-spacing: 0.5px;
    text-transform: none;
    border-style: solid;
    border-width: 1.5px;
    border-color: white;
    -webkit-font-smoothing:antialiased;
    background-position: 93% 50%;
    background-repeat: no-repeat;

  -o-transition:.5s;
  -ms-transition:.5s;
  -moz-transition:.5s;
  -webkit-transition:.5s;
  transition:.5s;
}

.item h4:hover {
    position: absolute;
    max-width: 200px;
    text-align: center;
    width: 100%;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    line-height: 43px;
    font-size: 16px;
    left: 8.5%;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: 10px;
    padding-right: 46px;
    margin-top: 0px;
    color: white;

    background: url(../images/arrow_btn_banner.png) no-repeat;
    background-size: 30px 30px;

    background-position: 93% 50%;
    border-radius: 6px; 
    letter-spacing: 0.5px;
    text-transform: none;
    border-style: solid;
    border-width: 1.5px;
    border-color: white;
    -webkit-font-smoothing:antialiased;
}

我尝试在背景图像上方放置背景大小,但这不起作用。我试过改变图像的大小。但这也行不通。

【问题讨论】:

  • 刚刚在 chrome 上测试过,似乎工作正常。
  • 我用 30x30 的图像对其进行了测试,并且工作正常,但是当我使用更大的图像对其进行测试时,它与您的网站完全一样。你说你试图改变图像大小,但你需要正好 30x30 的图像

标签: html css hover background-image


【解决方案1】:

也许您应该在h4 中将background-imagebackground-size 设置为0 并且只在h4:hover 上重置background-size,所以bg 图像已经加载。

【讨论】:

  • 成功了!检查结果:www.stilld.nl/nieuw。
猜你喜欢
  • 2014-08-01
  • 2011-07-03
  • 2017-03-29
  • 1970-01-01
  • 2012-07-02
  • 2016-10-25
  • 2012-01-15
  • 2023-03-08
  • 1970-01-01
相关资源
最近更新 更多