2014-02-21 26 views
0

嗨,我想知道DOCTYPE要打破我的一些CSS,但不是所有的

我創建了一個簡單的網頁上除了IE的所有瀏覽器運行得很好用!DOCTYPE HTML的。 研究它建議我使用的問題!DOCTYPE html。然而,這似乎否定了我的一些CSS,但並不是全部。

我看着它,唯一能找到的建議是我的id標籤和.css#標籤之間的拼寫錯誤。

我有一小塊java腳本仍然可以正常工作。我的2個div工作正常,允許用戶在提交按鈕停留在屏幕上時滾動。

但我失去了我的CSS和主頁按鈕。它的所有包裹在可能造成這個問題的一些老同學ASP正如我以前只使用asp.net

<% 
    Set Cn = Server.CreateObject("ADODB.Connection") 
    Cn.Open CnString 
    ' Build Sql. 
    Sql = "SELECT [USER_CODE],[WINDOWS_ID], [FIRST_NAME], [LAST_NAME], [ACTIVE_IND] FROM  FSUSER ORDER BY [LAST_NAME]" 
    ' Open recordset. 
    Set Rs = Cn.Execute(Sql) 
    If Not Rs.Eof Then arrayActiveUsers = Rs.GetRows() 
    Rs.Close 
    Set Rs = Nothing 
    Response.Write "<form action='main1.asp' method='post'>" 
    Response.Write "<div id=""top"">" 
    Response.Write "<button name=""regions1"" type=""submit"" value="&regions&" >Save_"&regions&"</button>" 
    Response.Write "<a href=""default.asp"" id=""home"" onclick=""return confirm('Have you saved your changes before leaving this page?');"" >Home</a>" 
     Response.Write "</div>" 
     Response.Write "<div id=""bottom"">" 
     Response.Write "<table id=""table1"">" 
     Response.Write "<tr>" 
     Response.Write "<td>User Code</td>" 
     Response.Write "<td>Windows ID</td>" 
     Response.Write "<td>First Name</td>" 
     Response.Write "<td> Last Name</td>" 
     Response.Write "<td> Status</td>" 
     Response.Write "<td> ACTIVATE</td>" 
     Response.Write "<td> DE-ACTIVATE</td>" 
     Response.Write "</tr>" 

     Response.Write "<tr>" 
For j = 0 To UBound(arrayActiveUsers,2) 
if arrayActiveUsers(4,j) = 1 then 
     Response.Write "<td>" & arrayActiveUsers(0,j) & "</td>" 
     Response.Write "<td>" & arrayActiveUsers(1,j) & "</td>" 
     Response.Write "<td>" & arrayActiveUsers(2,j) & "</td> " 
     Response.Write "<td>" & arrayActiveUsers(3,j) & "</td>" 
     Response.Write "<td ><font color=""green"">Active</font></td>" 
     Response.Write "<td></td>" 
     Response.Write "<td><input type=""checkbox"" name=""active"" value=" & arrayActiveUsers(0,j) &" /></td>" 

Response.Write "</tr>" 
else  
     Response.Write "<td>" & arrayActiveUsers(0,j) & "</td>" 
     Response.Write "<td>" & arrayActiveUsers(1,j) & "</td>" 
     Response.Write "<td>" & arrayActiveUsers(2,j) & "</td> " 
     Response.Write "<td>" & arrayActiveUsers(3,j) & "</td>" 
     Response.Write "<td><font color=""red"">Not Active</font></td>" 
     Response.Write "</td>" & "<td><input type=""checkbox"" name=""de- active"" value=" & arrayActiveUsers(0,j) &" /></td>" 
     Response.Write "<td></td>" 

     Response.Write "</tr>" 
end if 
next 
Response.Write "</table>" 
Response.Write "</div>" 
Response.Write "</form>" 
Cn.Close 
Set Cn = Nothing 
%> 

所以這是HTML的標題:

<!DOCTYPE html> 
<HTML> 
<HEAD> 
    <link rel="stylesheet" type="text/css" href="main1.css"> 
<TITLE> Main </TITLE> 
    <script type="text/javascript"> 
      function greeting(){ 
       alert("Have you commited all your data?") 
      } 
     </script> 
</HEAD> 
<BODY> 

這是css:

#top{ 
top:0; 
position:fixed; 
background: white; 
} 

#bottom{ 
margin-top:40px; 
} 

#home{ 
display: inline; 
width: 115px; 
height: 24px; 
background: #E6E6E6; 
padding: 0px; 
text-align: center; 
border-width:2px; 
border-style:ridge; 
border-color: gray; 
color: black;  
} 

#table1{ 
padding:3; 
border:groove,2px,#f0f0f0; 
background-color:a0a0a0; 

} 

我很抱歉,我沒有發現任何明顯的錯誤。我知道CSS會在IE和其他瀏覽器上看起來不一樣,但如果有人能讓它工作,也許我可以爲IE瀏覽器創建2個樣式表,一個用於其他所有內容。

我要補充我已經嘗試了多種文檔類型都達到同樣的效果

回答

0

這將是更容易幫助,如果你能創建最終HTML中的jsfiddle所以我們可以測試它,這個問題可能會有一些不好的CSS代碼或HTML標記沒有正確關閉。

關於doctype的一些簡短評論:DOCTYPE聲明是總是必需的。如果你不寫它,那麼瀏覽器將以不同的方式呈現網站,因爲他們不知道應用哪個標準(特別是IE),所以你會在你的工作瀏覽器中看到你的樣式很好,但在其他瀏覽器中,你的網站會看起來很糟糕。考慮到,修改樣式可能會讓你重寫所有的css,因爲你用一個不好的標準寫了它(就像在純沙灘上建造房子一樣)。

+0

嗨 我在這裏創建了一個jsfiddle示例: http://jsfiddle.net/Vn8fp/ – user183200

+0

使用小提琴我解決了我的問題。 非常感謝您的建議:-) – user183200

1

我不知道閹這是該問題的原因,但<!DOCTYPE html>似乎只能是HTML5,我不知道那是你想要什麼。

對於HTML4最佳兼容性不使用框架時嘗試

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
+0

我已經試過那個太可惜了,沒有快樂。 – user183200

0

我有類似的問題。該解決方案我選擇:

  1. 我走過去在該網站的所有網頁,並代替聲明DOCTYPE的每一頁,我創建一個單一的包含文件(doctype.asp)
  2. 這個文件的內容是

    <!DOCTYPE html > 
    <!--[if lt IE 7]>  <html class="no-js lt-ie9 lt-ie8   lt-ie7" xmlns:fb="http://ogp.me/ns/fb#"> <![endif]--> 
    <!--[if IE 7]>   <html class="no-js lt-ie9 lt-ie8" xmlns:fb="http://ogp.me/ns/fb#"> <![endif]--> 
    <!--[if IE 8]>   <html class="no-js lt-ie9" xmlns:fb="http://ogp.me/ns/fb#"> <![endif]--> 
    <!--[if gt IE 8] ><!--> <html class="no-js" xmlns:fb="http://ogp.me/ns/fb#"> <!--<![endif]--> 
    
  3. 現在,當整個網站具有相同的DOCTYPE聲明我解決了與CSS的任何問題。

相關問題