网址:http://cyberbat.co.uk/test 容器边距: 自动不起作用,是否有其他方法可以让它在IE中居中显示。
编辑:请重新检查,index.php是错误的文件,我已将其替换为index.html。
网址:http://cyberbat.co.uk/test 容器边距: 自动不起作用,是否有其他方法可以让它在IE中居中显示。
编辑:请重新检查,index.php是错误的文件,我已将其替换为index.html。
<div class="page">
的容器,并将其text-align
设置为center
即可。
.page-holder{
text-align:center;
}
.page{
margin:0 auto;
}
<div class="page-holder">
<div class="page">
page content
</div>
</div>
对于某些愚蠢的浏览器,在父容器上使用此代码:
text-align: center
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
您的问题是定义文件类型和标准。如果您将以下代码添加到文件顶部,它将起作用!
<!DOCTYPE html>
,现在IE的行为符合预期。10x - Pavel Vlasovdisplay: flex;
align-items: center;
<?php
include('inc/settings.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php include ?>
将不会呈现为字面值。如果我没有记错的话,请将 .ini 文件中的此行进行调整:AddType application/x-httpd-php .html .htm .php
对于IE浏览器,将"my-auto"替换为"align-self-center"即可。您还可以编写相应的CSS:
.center-container{
align-self: center;
}
align-self
是一个 flexbox 属性,只有在 flexbox 容器中才能使用。 - Quangdao Nguyen<?php
include('inc/settings.php');
?>
移除它; margin: auto
可在IE6+中使用。不需要进行 text-align: center
或其他不必要的更改。
<?php ...
(在浏览器中按 Ctrl+U 显示源代码)。 - duri<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<main class="container></main>
CSS:
.container {
margin-left: auto;
margin-right: auto;
width: 600px;
.page
创建一个容器,其text-align
应设置为center
。IE无法通过margin
使块标签(例如div
或ul
)居中。请参见下面的答案中的代码。 - amiry jd