2014-05-09 32 views
0

http://oi62.tinypic.com/33lo87l.jpg我應該如何設置文字位置?

enter image description here

導航和條幅都是在一個文件中。 'banner.php'

我想定位除登錄導航之外的「登錄成功」文本!

我試過margin-top:0px;但其仍banner.php的內容後顯示

我的CSS:

#container{ 
    background-color:white; 
    margin-left:auto; 
    margin-right:auto; 
    width:800px; 
    height:auto; 
} 

#content_container{ 
    background-color:red; 
    text-align:left; 
    margin-top:0px; 
    margin-left:155px; 
} 

body { 
    background-image:url(thebackground.png); 
    width:100%; 
} 

這是HTML代碼:

Banner.php的
<div id="container"> 
<?php include 'banner.php'; ?> 
<div id="content_container"> 
<h1>Login Successful <?php echo $_SESSION['username']?></h1> 
</div> 
</div> 

CSS代碼:

<style> 


#nav 
{ 
margin-left:auto; 
width:800px; 
} 

a:link {text-decoration:none;} 
a:visited {text-decoration:none;} 
a:hover {text-decoration:none;} 
a:active {text-decoration:none;} 
#tbl1 
{ 
font-family: Calibri; 
border-collapse:collapse; 
border:1px solid #b9ccdc; 
} 
#tbl1 td 
{ 
font-size:15px; 
border:1px solid #b9ccdc; 
} 
#tbl1 th 
{ 

font-size:17px; 
height:32px; 
width:150px; 
background: -moz-linear-gradient(#6298c2, #82b2d8); 
color:#f7fbff; 
} 

tr:hover 
{ 
background: #deeaf4; 
} 
</style> 
+0

顯示「banner.php」的內容 – Cyclonecode

+0

我已更新帖子。 – user3545779

+0

使用['float:left'](http://www.w3schools.com/cssref/pr_class_float.asp)作爲菜單並給它'width'。否則,'div'被設置爲'display:block',它的寬度爲100%。 – machineaddict

回答

0

如果橫幅是div(列表)或任何塊元素,您應該使用float:

#nav{ 
    width: 200px; 
    float: left; 
} 

#content_container { 
    width: 600px; 
    float: left; 
} 

然後使用一些clearfix方法清除。另外,你將#nav的寬度設置爲800px。它不應該寧願採取整個屏幕。可能的clearfix方法在這裏介紹:http://css-tricks.com/snippets/css/clear-fix/

+0

Nopes ..它出現在導航表下面。除了導航之外,我想要它......在右側。 – user3545779

+0

刪除您的#nav的餘裕。您還應該閱讀更多關於浮動如何工作的信息,例如http://www.smashingmagazine.com/2007/05/01/css-float-theory-things-you-should-know/ –

+0

Ohkk!現在我越來越像這樣: http://oi57.tinypic.com/2rdxp3b.jpg 現在我該如何把它呢?除了導航? – user3545779