2014-10-20 43 views
2

這是我的第一篇文章,我已經離開了HTML和CSS很長一段時間,所以請原諒我,如果這是一個明顯的問題,或者如果我的代碼混亂或不一致。我必須在我正在處理的頁面中查找此日誌的部分不同解決方案。表格在Firefox和IE中完全消失

我的問題是,雖然此頁面在Chrome和Opera,Firefox和Internet Explorer中均正常工作,但鏈接和按鈕消失之前的所有內容都會停留在頁面頂部。

你能幫我解釋爲什麼這可能是?

需要特殊字符,因爲這將是瑞典語。

HTML:

<html> 
    <head> 
    <link type="text/css" rel="stylesheet" href="stylesheet.css"/> 
    </head> 
    <body> 
    <div id="logindiv"> 
     <img src="AAA.png" style="width: 80px; height: 80px;"/> 
     <img src="BBB.jpg" style="width: 80px; height: 80px;"/> 

     <h1>V&auml;lkommen</h1> 
     <br/><br/><br/><br/> 

     <div id="logindiv"> 
     <table> 
      <tr> 
      <td></td> 
      </tr> 
      <tr> 
      <td><img src="user.png"/></td> 
      <td><input type="text" value="anv&auml;ndarnamn" name="username" id="user" style="color: #BCC8CC; text-align: center; font-family: 'jaapokki-regular', Helvetica, sans-serif;" 
       onblur="if (this.value == '') {this.value = 'anv&auml;ndarnamn';} this.style.color='#BCC8CC';" 
       onfocus="if (this.value == 'anv&auml;ndarnamn') {this.value = '';} this.style.color='#606060';" /></td> 
      </tr> 
      <tr> 
      <td><img src="password.png"></td> 
      <td><input type="password" value="l&ouml;senord" name="pwd" id="pwd" style="color: #BCC8CC; text-align: center; font-family: 'jaapokki-regular', Helvetica, sans-serif;" 
       onblur="if (this.value == '') {this.value = 'l&ouml;senord';} this.style.color='#BCC8CC';" 
       onfocus="if (this.value == 'l&ouml;senord') {this.value = '';} this.style.color='#606060';" /></td> 
      </tr> 
     </table> 

     <p><a href="password.html">Har du gl&ouml;mt ditt l&ouml;senord?</a></p> 

     <table> 
      <tr> 
      <td></td> 
      <td id="login"><a href="cases.html"><input type="button" name="btn" class="btn-style" value="LOGGA IN"/></a></td> 
      </tr> 
     </table> 
     <p></p> 
     </div> 

    </div> 

    </body> 
</html> 

CSS:

@font-face { 
    font-family: 'jaapokki-regular'; 
    src: url('jaapokki-regular.eot'); 
    src: url('jaapokki-regular.eot?#iefix') format('embedded-opentype'), 
     url('jaapokki-regular.woff') format('woff'), 
     url('jaapokki-regular.ttf') format('truetype'), 
     url('jaapokki-regular.svg#jaapokki-regular') format('svg'); 
    font-weight: normal; 
    font-style: normal; 
} 

a { 
    color: #6e8196; 
    text-decoration: none; 
} 

body { 
    background-color: #FFFEF5; 
    color: #606060; 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
} 

h1 { 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
    text-align: center; 
    color: #606060; 
} 

div#logindiv { 
    position: relative; 
    top: 50%; 
    transform: translateY(-50%); 
    text-align: center; 
} 

table { 
    width: 220px; 
    position: relative; 
    left: 50%; 
    transform: translateX(-50%); 
    text-align: center; 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
} 

td { 
    height: 50px; 
    vertical-align: middle; 
} 

td#login { 
    height: 80px; 
    vertical-align: middle; 
} 

.user-style{ 
    color: #606060; 
} 
.btn-style{ 
    border : solid 1px #606060; 
    font-size : 17px; 
    color : #fffef5; 
    padding : 4px 12px; 
    background-color : #6e8196; 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 

} 
+0

我不確定你是否理解職位的目的:相對於我認爲你想要做的事情....如果你想要集中的東西,嘗試使用'margin:0 auto;' – briansol 2014-10-20 21:14:13

+0

我想你可以檢查CSS轉換的瀏覽器兼容性。 http://www.w3schools.com/cssref/css3_pr_transform.asp – 2014-10-20 21:15:03

+0

你是對的@briansol;我不明白它的許多事情,因爲正如我所說的,我只能在長期缺席之後重新開始寫腳本。感謝您的建議,我會檢查出來。 – 2014-10-20 21:19:51

回答

0

有一個規則,使整個表出去的畫面。

div#logindiv { 
    transform: translateY(-50%); 
} 

結果沒有它:

@font-face { 
 
    font-family: 'jaapokki-regular'; 
 
    src: url('jaapokki-regular.eot'); 
 
    src: url('jaapokki-regular.eot?#iefix') format('embedded-opentype'), 
 
     url('jaapokki-regular.woff') format('woff'), 
 
     url('jaapokki-regular.ttf') format('truetype'), 
 
     url('jaapokki-regular.svg#jaapokki-regular') format('svg'); 
 
    font-weight: normal; 
 
    font-style: normal; 
 
} 
 

 
a { 
 
    color: #6e8196; 
 
    text-decoration: none; 
 
} 
 

 
body { 
 
    background-color: #FFFEF5; 
 
    color: #606060; 
 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
 
} 
 

 
h1 { 
 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
 
    text-align: center; 
 
    color: #606060; 
 
} 
 

 
div#logindiv { 
 
    position: relative; 
 
    top: 50%; 
 
    /* transform: translateY(-50%); */ 
 
    text-align: center; 
 
} 
 

 
table { 
 
    width: 220px; 
 
    position: relative; 
 
    left: 50%; 
 
    transform: translateX(-50%); 
 
    text-align: center; 
 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
 
} 
 

 
td { 
 
    height: 50px; 
 
    vertical-align: middle; 
 
} 
 

 
td#login { 
 
    height: 80px; 
 
    vertical-align: middle; 
 
} 
 

 
.user-style{ 
 
    color: #606060; 
 
} 
 
.btn-style{ 
 
    border : solid 1px #606060; 
 
    font-size : 17px; 
 
    color : #fffef5; 
 
    padding : 4px 12px; 
 
    background-color : #6e8196; 
 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
 

 
}
<div id="logindiv"> 
 
     <img src="AAA.png" style="width: 80px; height: 80px;"/> 
 
     <img src="BBB.jpg" style="width: 80px; height: 80px;"/> 
 

 
     <h1>V&auml;lkommen</h1> 
 
     <br/><br/><br/><br/> 
 

 
     <div id="logindiv"> 
 
     <table> 
 
      <tr> 
 
      <td></td> 
 
      </tr> 
 
      <tr> 
 
      <td><img src="user.png"/></td> 
 
      <td><input type="text" value="anv&auml;ndarnamn" name="username" id="user" style="color: #BCC8CC; text-align: center; font-family: 'jaapokki-regular', Helvetica, sans-serif;" 
 
       onblur="if (this.value == '') {this.value = 'anv&auml;ndarnamn';} this.style.color='#BCC8CC';" 
 
       onfocus="if (this.value == 'anv&auml;ndarnamn') {this.value = '';} this.style.color='#606060';" /></td> 
 
      </tr> 
 
      <tr> 
 
      <td><img src="password.png"></td> 
 
      <td><input type="password" value="l&ouml;senord" name="pwd" id="pwd" style="color: #BCC8CC; text-align: center; font-family: 'jaapokki-regular', Helvetica, sans-serif;" 
 
       onblur="if (this.value == '') {this.value = 'l&ouml;senord';} this.style.color='#BCC8CC';" 
 
       onfocus="if (this.value == 'l&ouml;senord') {this.value = '';} this.style.color='#606060';" /></td> 
 
      </tr> 
 
     </table> 
 

 
     <p><a href="password.html">Har du gl&ouml;mt ditt l&ouml;senord?</a></p> 
 

 
     <table> 
 
      <tr> 
 
      <td></td> 
 
      <td id="login"><a href="cases.html"><input type="button" name="btn" class="btn-style" value="LOGGA IN"/></a></td> 
 
      </tr> 
 
     </table> 
 
     <p></p> 
 
     </div> 
 

 
    </div>

+0

非常感謝,@emmanuel。該代碼是我發現的一種以垂直居中爲中心的簡單方法。事實上,評論它確實帶回了這些元素,但是它們的垂直排列全都沒有問題。我想我可以多看看它,回來或者爲這個問題提出一個不同的問題。不知道這裏的協議是什麼。 – 2014-10-20 21:23:05

+0

很高興聽到!如果你想垂直對齊整個div的中間,你可以使用'vertical-align'屬性。 – emmanuel 2014-10-20 21:27:12

0

原來,廢除變換完全是更好的。取而代之的是,我用這些小比特來居中我的div和表格:

div { 
    position:absolute; 
    top:25%; 
    left:25%; 
    right:25%; 
} 

table#login { 
    width: 220px; 
    margin: 0 auto; 
    text-align: center; 
    font-family: "jaapokki-regular", Helvetica, sans-serif; 
} 

table { 
    margin: 0 auto; 
    text-align: center; 
} 

感謝大家的幫助。