【问题标题】:auto width overlay div not working in IE自动宽度覆盖 div 在 IE 中不起作用
【发布时间】:2016-01-18 06:43:40
【问题描述】:

我有一个以缩略图页面开始的画廊页面。当您单击缩略图时,它会填充一个隐藏的 div,然后显示该 div。显示 div 具有基于图像的自动宽度和 700 像素的最大高度,溢出:自动;。

这在任何地方都可以正常工作,除了 IE。在 IE 中,div 显示为一条细线,而我终于发现,图像大部分显示在屏幕左侧。

我在下面包含了 HTML 和 CSS。你会在那里看到一些 Angular 变量。这是 JS 自动填充的内容。

HTML:

<div id="siteCover" ng-show="picID > 0">
</div>

<div id="outerPictureDisplay" ng-show="picID > 0">
<div id="innerPictureDisplay">
<div id="divClose" class="floatRight" ng-click="picID = 0;">Close</div>
<div id="picNavPrev" ng-click="picturePop({{prevID}});"><img src="images/arrowLeft.png" /></div>
<div id="picNavNext" ng-click="picturePop({{nextID}});"><img src="images/arrowRight.png" /></div>
<img src="images/photos/{{thisPic.image}}" id="displayedImage" />
<p ng-show="thisPic.title != ''"><b>{{thisPic.title}}</b></p>
<p ng-show="thisPic.desc != ''">{{thisPic.desc}}</p>
</div>
</div>

CSS:

#outerPictureDisplay{
z-index: 500;
top: 50px;
left: 50%;
padding: 0px;
position: fixed;
} 

#innerPictureDisplay{
left: -50%;
min-height: 200px;
height: auto;
max-height: 700px;
width: auto;
padding: 0px;
position: relative;
overflow: auto;
background-color: @lightcolor;
.bordered-dark;
.rounded;
& img{
    margin: 0px;
    padding: 0px;
    }
}

#divClose{
font-size: 1em;
background-color: @darkcolor;
color: @lighttextcolor;
display: inline-block;
padding: 5px;
right: 0;
position: absolute;
}

#picNavPrev{
display: inline-block;
padding:0;
top:40%;
float: left;
height: auto;
position: absolute;
}

#picNavNext{
display: inline-block;
padding:0;
top:40%;
float: right;
right: 0;
height: auto;
position: absolute;
}

#siteCover{
width: 100%;
height: 100%;
background:rgba(0, 0, 0, 0.7);
z-index: 450;
position: fixed;
top: 0;
left: 0;
}

如何在 IE 中也按预期工作?

【问题讨论】:

  • 您应该添加您正在使用的 IE 和 Angular 版本。 MCVE 还可以帮助您获得答案。
  • Angular 1.2.26 IE: 11(但我认为其他版本也有)什么是 MCVE?
  • 另一种想法,您可能想要对属性进行编码。例如,ng-show="picID &gt; 0" 中的 &gt; 可能会导致问题。

标签: css internet-explorer


【解决方案1】:

您只能为 IE 创建样式表:

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="ie-stylesheet.css" />
<![endif]-->

或者您可以为特定版本的 IE 制作样式表,例如我想为版本 7 制作特定样式表:

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="ie7.css">
<![endif]-->

只需将括号中的数字替换为您拥有的版本号即可。

【讨论】:

  • 这很好,但是我需要在 IE 的 CSS 中做些什么不同的事情是我的问题?
  • 我认为问题出在:inline-block;因为它有时会导致 IE 出现问题,所以尝试将其替换为:display:-moz-inline-stack;显示:内联块;缩放:1; *显示:内联;
  • 记住 Mozilla Firefox 不支持 display: inline-block;所以无论如何你都必须更换它。
猜你喜欢
  • 1970-01-01
  • 2023-03-03
  • 2012-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-28
  • 2014-11-01
  • 2018-01-06
相关资源
最近更新 更多