2016-06-28 71 views
0

我有一個用php(html)和css編寫的網站,我的問題是,有時(通常在重定向之後),css對齊中斷,除了標題圖片之外,一切到左上角。在我的電腦上(即使這樣,我已經在談論上傳到主機服務器上的網站),我可以通過刷新頁面來解決這個問題,突然之間,一切都應該是這樣。在不同的設備上(我曾在2臺不同的計算機和3部手機上試過),它從來沒有以正確的方式顯示出來。我已經在不同的瀏覽器(Firefox,Chrome,手機瀏覽器...)上嘗試了這一點,但它沒有任何區別,所以顯然問題是我的編碼:D 如果有人感興趣,我張貼我的CSS代碼,如果不,只需跳過它。CSS對齊不能在不同的設備上工作

body{ 
 
\t font-family: Arial, sans-serif; 
 
\t font-size: 12pt; 
 
\t height: 100%; 
 
\t width: 100%; 
 
\t margin: 0px; 
 
} 
 
#page{ 
 
\t overflow: auto; 
 
\t background: #B6B1B1 url('img/background.JPG') no-repeat center; 
 
\t background-attachment: fixed; 
 
} 
 
img{ 
 
\t max-width: 100%; 
 
\t height: auto; 
 
\t width: auto\9; 
 
} 
 
#languages li a{ 
 
\t font-weight: bold; 
 
\t color: #191045; 
 
} 
 
#languages li a:hover{ 
 
\t color: #E49900; 
 
} 
 
h1 a span{ 
 
\t display: none; 
 
} 
 
h1 a{ 
 
\t width: 100%; 
 
\t height: 240px; 
 
\t display: block; 
 
\t position: absolute; 
 
\t background: transparent url('img/headerpic.png') no-repeat top center; 
 
} 
 
#menubar{ 
 
\t width: 70%; 
 
\t position: absolute; 
 
\t margin: 220 15% 0 15%; 
 
\t text-align: center; 
 
} 
 
#menu li{ 
 
\t display: inline-block; 
 
\t height: 40px; 
 
\t line-height: 40px; 
 
\t margin-top: 20; 
 
\t margin-left: 5px; 
 
\t padding: 0 15 0 15; 
 
\t background-color: rgba(25,16,69,0.85); 
 
\t border-radius: 5px; \t 
 
} 
 
#menu .selected{ 
 
\t background-color: rgba(255,255,255,0.85); 
 
\t border-style: solid; 
 
\t border-width: 3px; 
 
\t border-color: rgba(25,16,69,0.85); 
 
} 
 
#menu .selected a{ 
 
\t color: rgba(25,16,69,0.85); 
 
} 
 
#menu li a{ 
 
\t text-decoration: none; 
 
\t color: white; 
 
} 
 
#menu li a:hover{ 
 
\t color: #E49900; 
 
} 
 

 
#main{ 
 
\t min-height: 350; 
 
\t position: relative; 
 
\t display:block; 
 
\t background-color: rgba(255,255,255,0.85); 
 
\t width: 70%; 
 
\t margin-left: 15%; 
 
\t margin-right: 15%; 
 
\t margin-top: 340; 
 
\t padding: 15 15 15 15; 
 
\t border-radius: 10px; 
 
\t color: black; 
 
} 
 
footer{ 
 
\t position: relative; 
 
\t background-color: rgba(255,255,255,0.85); 
 
\t width: 70%; 
 
\t margin-left: 15%; 
 
\t margin-right: 15%; 
 
\t margin-top: 15; 
 
\t padding: 2.5 15 2.5 15; 
 
\t border-radius: 10px; 
 
\t display: inline-block; 
 
\t bottom: 5px; 
 
\t color: black; 
 
\t font-size: 80%; 
 
\t text-align: center; 
 
} 
 
#footer a{ 
 
\t text-decoration: none; 
 
\t color: black; 
 
} 
 
#footer a:hover{ 
 
\t color: #E49900; 
 
}

感謝您對所有的提示:)

+1

試着讓你的問題更加簡潔,只包括你需要的東西;沒有太多人想要閱讀那些文字和代碼的牆。 –

+0

修復你的CSS:'width:auto \ 9;'。 auto9? –

+0

@AnonyAstige對不起,如果太長了,我只是想詳細解釋一下,因爲通常有人告訴我,我的解釋不是很有幫助......現在我不知道該跳過什麼:D –

回答

0

所以,我「哦,這麼大的錯誤」是,我沒有寫單位後面的數字保證金,填充等...我簡單地寫了例如10.當我添加px/em ...在它後面,突然一切正常:D

仍然不知道爲什麼花了我這麼長時間才意識到它。 .__

相關問題