【发布时间】:2017-04-29 16:24:22
【问题描述】:
input[type=text], input[type=password], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
background-color: #808080;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #A9A9A9;
}
html,body {
height:100%;
width:100%;
margin:0;
}
body {
display:flex;
background-color:#D3D3D3;
}
form {
margin:auto;
}
上面的 CSS 代码使表单中心在 Chrome 和 Firefox 中对齐,但在 Internet Explorer 中不起作用。在 IE 中,表单水平居中对齐,但不是垂直居中。有什么问题以及如何使其在 IE 中正确对齐?
【问题讨论】:
-
样式必须在头部内
-
为什么样式应该在头部?
-
因为是html约定w3schools.com/html/html_css.asp
-
好的,我已将它包含在 head 部分中。仍然 css 似乎没有在 IE 中正确应用?那么有什么建议吗?
-
flex 在 IE 中只有部分支持;它在 ie10 中支持较旧的语法,并且由于存在大量错误,在 ie11 中仅支持部分语法。请参阅caniuse.com/#search=flex 这是您问题的最可能原因,但边缘应该没问题