【发布时间】:2019-07-22 04:36:39
【问题描述】:
Here is result in Chrome which is right
Here is result in IE which is wrong
这里是代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body, div, html
{
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
width: 100%;
}
form
{
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
max-width: 1280px;
width: 100%;
}
img
{
flex: none;
max-width: 100%;
min-height: 1px;
width: 100%;
}
picture {width: 80%;}
#temp {background-color: red;}
</style>
</head>
<body>
<form id="form1">
<picture>
<source media="(max-width: 600px)" srcset="../tmp.jpg">
<source media="(max-width: 960px)" srcset="../tmp.jpg">
<img src="../tmp.jpg">
</picture>
<div id="temp">123123123123</div>
</form>
</body>
</html>
为什么 ie 中的图片元素在 chrome 中没有出现这个空白? IE版本是Windows 10中的IE 11,Chrome版本是57.0.2987.110。 IE有什么问题? 以及如何删除 IE 中的空白?谢谢
【问题讨论】:
-
因为IE不支持这个元素? caniuse.com/#search=picture MS 中的第一个支持是 Edge 13
-
我又试了几次,发现问题似乎出在flexbox上。如果不用flexbox,已经可以了。可能flexbox和图片元素有点麻烦。
-
IE11不支持图片元素。 caniuse.com/#picture 并呈现为 HTMLUnknown 的内联元素。要解决此问题,只需删除图片{width:80%} 规则...(图片元素是分组元素,即它们将一组 img 元素分组)
-
感谢 Rob Parsons 的回复。我尝试删除图片{width:80%} 规则,它使用了。但是我需要将宽度减小到 80%。我尝试将它的父 div 宽度设置为 80 %,但问题又来了。如何将宽度设置为 80%?
标签: html css internet-explorer