首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >响应式标头中CSS背景转换的问题

响应式标头中CSS背景转换的问题
EN

Stack Overflow用户
提问于 2014-04-12 08:12:26
回答 1查看 176关注 0票数 0

我正在尝试获得一个标题,它变得更小的滚动为my site制作。它工作得很好,但尽管CSS中包含了过渡,但只有当小标题转换为大标题(向上滚动)时,标题中的图像才会平滑过渡,反之亦然。它现在看起来有点抖动/小故障。

下面是我对图像的CSS:

徽标:

代码语言:javascript
复制
.Logo.small:hover {
    background: url("images/Logo.png") no-repeat;
    background-size: contain;
    position: absolute;
    top: 8px;
    width: 40px;
    height: 40px;
    z-index: 73;
    -webkit-transition: background-image .5s;
          -webkit-transition: height 0.6s;
    -moz-transition: height 0.6s;
    transition: height 0.6s;
          -webkit-transition: width 0.6s;
    -moz-transition: width 0.6s;
    transition: width 0.6s;
}
.Logo:hover {
  background: url("images/LogoHover.png") no-repeat;
  background-size: contain;
  position: absolute;
  top: 8px;
  width: 81px;
  height: 85px;
  z-index: 70;
  -webkit-transition: background-image .5s;
}
.Logo {
    background: url("images/Logo.png") no-repeat;
    background-size: contain;
    position: absolute;
    top: 8px;
    width: 81px;
    height: 85px;
    z-index: 73;
    -webkit-transition: background-image .5s;
    -webkit-transition: width .5s;
    -webkit-transition: height .5s;
}
.Logo.small {
    background: url("images/Logo.png") no-repeat;
    background-size: contain;
    position: absolute;
    top: 8px;
    width: 40px;
    height: 40px;
    z-index: 73;
    -webkit-transition: background-image .5s;
    -webkit-transition: width .5s;
    -webkit-transition: height .5s;
}

社交图标1:

代码语言:javascript
复制
.Icon_BG1 {
  background: url("images/IconBG.png") no-repeat;
    background-size: contain;
  position: absolute;
  margin-left: 905px;
  top: 26px;
  width: 45px;
  height: 48px;
  z-index: 80;
  -webkit-transition: background-image .5s;
    -webkit-transition: width .5s;
  -webkit-transition: height .5s;
}
.Icon_BG1.small {
  background: url("images/IconBG.png") no-repeat;
  position: absolute;
  margin-left: 905px;
  top: 10px;
  background-size: contain;
  width: 35px;
  height: 35px;
  z-index: 80;
  -webkit-transition: background-image .5s;
  -webkit-transition: width .5s;
  -webkit-transition: height .5s;
}
.Icon_BG1.small:hover {
  background: url("images/IconBGHover.png") no-repeat;
  position: absolute;
  margin-left: 905px;
  top: 10px;
  background-size: contain;
  width: 35px;
  height: 35px;
  z-index: 80;
  -webkit-transition: background-image .5s;

}
.Icon_BG1:hover {
  background: url("images/IconBGHover.png") no-repeat;
  position: absolute;
  margin-left:905px;
  top: 26px;
  width: 45px;
  height: 48px;
  z-index: 80;
  -webkit-transition: background-image .5s;
}

社交图标2:

代码语言:javascript
复制
.Icon_BG_2 {
  background: url("images/IconBG2.png") no-repeat;
  background-size: contain;
  position: absolute;
  margin-left: 960px;
  top: 26px;
  width: 45px;
  height: 48px;
  z-index: 82;
  -webkit-transition: background-image .5s;
    -webkit-transition: width .5s;
  -webkit-transition: height .5s;
}
.Icon_BG_2.small {
  background: url("images/IconBG2.png") no-repeat;
  background-size: contain;
  position: absolute;
  margin-left: 960px;
  top: 10px;
  width: 35px;
  height: 35px;
  z-index: 82;
  -webkit-transition: background-image .5s;
    -webkit-transition: width .5s;
  -webkit-transition: height .5s;
}
.Icon_BG_2.small:hover {
  background: url("images/IconBGHover2.png") no-repeat;
  background-size: contain;
  position: absolute;
  margin-left: 960px;
  top: 10px;
  width: 35px;
  height: 35px;
  z-index: 82;
  -webkit-transition: background-image .5s;
}
.Icon_BG_2:hover {
  background: url("images/IconBGHover2.png") no-repeat;
  position: absolute;
  margin-left:960x;
  top: 26px;
  width: 45px;
  height: 48px;
  z-index: 82;
  -webkit-transition: background-image .5s;
}
EN

回答 1

Stack Overflow用户

发布于 2014-04-12 08:58:33

这是因为您使用background-size而不是transform来调整图像大小

使用

代码语言:javascript
复制
transform: scale(xx);

用于调整大小

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23024529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档