【问题标题】:css background-position not working in IE 7 and 8css 背景位置在 IE 7 和 8 中不起作用
【发布时间】:2016-11-17 22:27:11
【问题描述】:

此页面在 FF、Chrome 等中呈现出色。但是在 IE 7 和 8 中,作为背景图像的关闭“X”没有对齐。有任何想法吗?我尝试设置background-position等。

我的代码:

.startup-container
{
  width: 455px;
}

.close-startup-home 
{
  background: #c00 url("http://spotlightonhealthyliving.com/btn_closex.png") 0px -8px no-repeat;
  float: right;
  height: 52px;
  width: 60px;
}

.menu-outer
{
  background: #545454;
  -moz-border-radius:5px; 
  border-radius:5px;
  -moz-box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, .4);
  box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, .4);

}

.menu-inner
{
  background: #3f3f3f;
  -moz-box-shadow: inset 0px 0px 4px 3px rgba(0, 0, 0, .1);
  box-shadow: inset 0px 0px 4px 3px rgba(0, 0, 0, .1);
  -moz-border-radius:5px; 
  border-radius:5px;
}

.startup-box
{
  width:439px;
  line-height:20px;
  text-align: center;
  color:#fff;
  padding-top:5px;
  padding-bottom:5px;
}

.startup-box-inner
{
  width:389px; 
  height:99px;
  padding:20px;
  margin-left:5px;
  margin-right:5px;
}
<div class="startup-container">
  <div class="close-startup-home"></div>
  <div class="menu-outer startup-box">
    <div class="menu-inner startup-box-inner"></div>
  </div>
</div>

【问题讨论】:

  • 在 IE8 中工作正常
  • @Pekka IE7 模拟它没有但 IE8 它工作正常。老实说,现在还有人使用 IE7 吗?

标签: css internet-explorer cross-browser


【解决方案1】:

给你的 div 一个 position: absolute 包含关闭按钮并根据它定位。

.startup-container {
    width: 455px;
    position: relative
}

.close-startup-home {
    background: #c00 url("http://spotlightonhealthyliving.com/btn_closex.png") 0px -8px no-repeat;
    float: right;
    height: 52px;
    width: 60px;
    position: absolute;
    right: 0; 
}

【讨论】:

  • 我必须添加一个 z-index: 到它,但除此之外......效果很好!你是最棒的!
猜你喜欢
  • 1970-01-01
  • 2011-07-15
  • 2011-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-30
  • 1970-01-01
相关资源
最近更新 更多