在php之后偏心的中心元素

时间:2013-06-18 04:48:15

标签: css

我的定位问题非常混乱。我有一个<img>元素 display:block;margin-left:auto;margin-right:auto;,它应该以它为中心。问题是它没有在容器中居中,而是看起来居中在容器的左半部分。

使问题复杂化,这只发生在链接的php文件

之后
<div class="header">
...
<nav id="menu" class="topnav">
<ul>
    <li><a class="navlink" href="alexandria.html"><br style="clear: both;"/>Alexandria<br style="clear: both;"/><span>Referencing Manager</span></a></li>
    <li><a class="navlink" href="ceryneian.html"><br style="clear: both;"/>Ceryneian<br style="clear: both;"/><span>Research Browser</span></a></li>
    <li><a class="navlink" href="blog"><br style="clear: both;"/>Blog<br style="clear: both;"/><span>Thoughts</span></a></li>
    <li><a class="navlink" href="about.html"><br style="clear: both;"/>About<br style="clear: both;"/><span>Our Team</span></a></li>
</ul>
</nav>

- 如果我删除它,它工作正常。 修改我一直在测试我的CSS,如果我删除了float:right;上的<ul>它可行 - 我不知道为什么,我想要尽可能保持浮动。

以下是有问题的页面http://fireoak.3owl.com/404.html - 如果您有任何帮助,请提前感谢。

2 个答案:

答案 0 :(得分:1)

Add foll0wing CSS to your content div  line -100(main_large.css)  

    border: 1px solid transparent;
    margin: 75px auto auto;

And css for img
    position: relative; (line 17 main_large.css)

答案 1 :(得分:0)

给父元素一个宽度(例如width:100%;),然后给你想要居中的子元素margin: 0 auto;,它应该为你居中。

此外,如果您在包含header.php时遇到问题,请确保您的HTML在该文件中有效。