2013-03-01 74 views
0

http://img.ctrlv.in/51305a45c3aa8.jpg如何中心“DIV的中心”,而不是“起点”的div

我面对这个问题,在我的响应式设计的网站,当我降低了浏览器约低于700像素的宽度。

我加入margin-left: auto; margin-right: auto;,但输出保持unchanged.If我把左:50%,这显示了一些奇怪的位置也许是因为我的头是postion:fixed(虽然我还没有提到它的顶部/左/右/底部的其他地方) 。

徽标“ilovetrolls”从页面中心开始....因此图像的中心不居中。 The page http://img.ctrlv.in/51305a532c7fd.jpg

任何帮助将是appreciated.Thanks很多

回答

1

只是删除这种风格

#header { 
    text-align: center; 
} 

放置直列线在媒体只有屏幕宽度没有428 767

+0

感谢一吨!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!请你可以告诉我的逻辑 – Michel 2013-03-01 08:31:55

+0

我只是看到你的代码ii发现 我不知道很多css 其刚刚击中并尝试在浏览器的检查元素 – 2013-03-01 10:55:40

+0

ohk ...非常感谢 – Michel 2013-03-01 11:00:45

1

您需要将#topdiv1的(线663)的display属性更改为display: block。我在我的Chrome网络检查员身边拨弄,并且以这种方式工作。不能伤害到floatfloat: none要么。

+0

非常感谢......... – Michel 2013-03-01 08:33:59

1

尝试是这样的:

<style> 
.container { 
    margin-left: auto; 
    margin-right: auto; 

    /* To see the affect of the above; not part of centering implementation. */ 
    background-color: #aaa; 
    width: 200px; 
} 
</style> 
<div class="container"> 
    Hello, world! 
</div> 
+0

非常感谢.... – Michel 2013-03-01 08:33:43

1

采取div.#topdiv3和删除float: left并添加margin-left: auto; margin-right: auto。然后移动div.#topdiv3div.#outter-wrapper

enter image description here