2014-03-27 30 views
0

對不起,我嘗試了一切,嘗試了三十分鐘卻得不到任何東西。好的,這是我的代碼。出於某種原因,「div2」不能正常工作,不能向下移動,只能左右移動。我希望它能夠從頂部或屏幕的底部,但它唯一的左右移動,並位於同一水平導航欄儘管排名最高的部門並沒有下移

body { 
    background-color: LightGoldenRodYellow; 
    font-family:"Arial Black", Gadget, sans-serif; 
} 

#rightcolumn { 
    float: left; 
margin-left: 100px; 
} 

#wrapper { 
background-color: #33CC00; 
color: #000066; 
} 

#midcolumn { 
    float: left; 
    width: 100px; 
    Margin: 15px; 
} 

#leftcolumn { 
float: left; 
width: 100px; 
margin: 10px; 
} 

#footer { 
    clear: both; 
    position: relative; 
    z-index: 10; 
    height: 3em; 
    margin-top: -3em; 
} 


    .navbar { 
    text-decoration: none; 
    margin: 15px; 
display: block; 
} 

.div2{ 
position:absolute; 
float: left; 
left: 200px; 
margin-top:100px: 
} 


.title{ 
color: LightCoral; 
position:absolute; 
left: 50%; 
top: 10%; 
} 

.titlesub{ 
color: Green; 
position:absolute; 
font-size: 12pt; 
left: 50%; 
top; 30%; 
} 


.content{ 
color: LightCoral; 
} 

確定下一個文件向下和向上移動

<!doctype htm> 

<html> 

<head> 
<link href="midterm_helper.css" rel="stylesheet" type="text/css" /> 
<title>Vacation Destination </title> 

</head> 


<body> 

<h1 class="title"> 

Vacation Island 

<p class="titlesub"> 

~vacation awaits! 

</p> 




</h1> 

<p class="div2"> 
     test 
     </p> 



     <div> 
      <a class="navbar" href="hotel_form.html" target="_blank">Reservations</a> 

      <a class="navbar" href="hotel_room.html"   target="_blank">Rooms</a> 

      </div> 




















</body> 

</html> 
+0

你的HTML不是很好的形式,該文檔是不正確......你可能想刪除你的未來的問題 – Jeffrey04

+0

不需要......空格字符不必要的空格字符?你的意思是所有的空白行? –

+0

是的,它使html標記難以閱讀 – Jeffrey04

回答

0

於從底部div2這給bottom價值,不妨到div

.div2{ 
    bottom:0; // change the value as you need 
} 
+0

謝謝你,像一個魅力工作。 –

+0

@ Shinji-san請接受並關閉這個如果你的問題解決 – James

+0

接受和關閉?對不起,這是新的:/ –

0

爲什麼你在課堂上給地位,並漂浮在同一時間。如果您使用的是position:absolute,則可以將值設爲topbottomleftright

另外你的HTML代碼真的搞砸了。刪除不需要的空間,並首先製作正確的HTML。

例如,您正在給位置並同時浮動元素。你應該一次只使用一個。

.div2{ 
position:absolute; /*either you should remove it*/ 
float: left; /*or you should remove this line*/ 
left: 200px; 
top:100px; 
left:0; 
} 
-1

您可以設置top向上和向下移動你的DIV2像你通過left

.div2{ 
top: 20px; /*set the value depending upon your requirement */ 
} 
1

設置如果你們真正看一遍他的代碼,你會看到他有一個冒號:之後他的頂級風格代替了分號;

這會做你想做的事情。浮動:左邊;是沒有必要的,雖然:)

.div2{ 
position:absolute; 
float: left; 
left: 200px; 
margin-top:100px; 
} 
+1

你是對的'margin-top:100px:'而不是'margin-top:100px;' –

+0

其他方式:) – Nick

+0

我在說什麼OP沒有他應該做的。 :) –