2012-04-26 93 views

回答

1

下一次,只有後在你的問題相關的代碼位。這使得人們更容易回答的可能性更大。

如果這是你指的是代碼:

<div id="header"> 
      <div id="site-title"> 
        <a href="http://www.panduzee.com/wordpress"><img src="http://i.imgur.com/ysxPP.jpg"></a> 
      </div> 
      <!-- other bits stripped for brevity --> 
      <div class="clear"></div> 
    </div> 

和CSS是這樣的:

#header { 
    border-bottom: 1px solid #dedfe0; 
    padding-bottom: 50px; 
} 
#site-title { 
    float: left; 
    width: 100%; 
    padding-right: 40px; 
    overflow: hidden; 
    line-height: 27px; 
    font-size: 23px; 
    display:block; 
    margin: auto; 
} 
#site-title a { 
    color: #333; 
    font-weight: bold; 
    text-decoration: none; 
} 

然後,你需要如下修改CSS:
1.刪除float: left從網站標題。不必要的。
2.請注意,您的padding-right of 40px將導致您的width: 100%
問題3.將text-align: center;添加到網站標題。
4.添加margin: 0 auto;到您的網站所有權

下面的代碼會做你想要什麼:

#header { 
    border-bottom: 1px solid #dedfe0; 
    padding-bottom: 50px; 
} 
#site-title { 
    width: auto; 
    padding-right: 40px; 
    overflow: hidden; 
    line-height: 27px; 
    font-size: 23px; 
    text-align: center; 
} 
#site-title a { 
    color: #333; 
    font-weight: bold; 
    text-decoration: none; 
    margin: 0 auto; 
} 
0

一下添加到#site-title

text-align: center; 
+0

您也可以使用#定點title img {display:block;保證金:0汽車; }。 http://dorward.me.uk/www/centre/ – reisio 2012-04-26 02:28:21

0

這應該工作:

#header { 
width: 500px; 
margin: 0 auto; 
} 
</style> 
<div id="header"> 
<!-- div content here --> 
</div>