2015-11-29 24 views
0

我真的有一個非常糟糕的時間,我的背景圖像無法正常工作。 這是我的CSS文件:CSS背景圖像和一些部門不工作

body 
     { 
      background-image:url('college_monitor.jpg'); 
      background-position:left center; 
      background-repeat: no-repeat; 
      background-size:contain; 
     } 

圖片是在同一文件夾中的HTML和CSS文件。

也有一些我的CSS部門的不正常工作,這是我司的CSS:

#FullName 
     { 
      margin-top:10px; 
      margin-left:400px; 
     } 
     #FirstName 
     { 
      font-size:0.9em; 
      color: cornflowerblue; 
      border: 2px solid lime; 
      border-radius: 25px; 
      background-color: black; 
      margin: 20px; 
      width: 150px; 
      text-align:center; 
     } 
     #FatherName 
     { 
      font-size:0.9em; 
      color: cornflowerblue; 
      border: 2px solid lime; 
      border-radius: 25px; 
      background-color: black; 
      margin: 20px; 
      width: 150px; 
      text-align:center; 
     } 
     #LastName 
     { 
      font-size:0.9em; 
      color: cornflowerblue; 
      border: 2px solid lime; 
      border-radius: 25px; 
      background-color: black; 
      margin: 20px; 
      width: 150px; 
      text-align:center; 
     } 
     #Diploma 
     { 
      margin-left:400px; 
      font-size:0.9em; 
      color: cornflowerblue; 
      border: 2px solid lime; 
      border-radius: 25px; 
      background-color: black; 
      margin: 20px; 
      width: 150px; 
      text-align:center; 
     } 
     #HighSchool 
     { 
      margin-left:400px; 
      font-size:0.9em; 
      color: cornflowerblue; 
      border: 2px solid lime; 
      border-radius: 25px; 
      background-color: black; 
      margin: 20px; 
      width: 150px; 
      text-align:center; 
     } 

和HTML文件:

<div id="FullName"> 
         <div id="FirstName"><b><h3>First name:</h3></b></div> 
          <input class="input" maxlength="10" name="first" type="text" value="" size="30" /> 

         <div id="FatherName"><label><b><h3>Father name:</h3></b></div> 
          <input class="input" maxlength="10" name="father" type="text" value="" size="30" /> 
         <div id="LastName"><b><h3>Last name:</h3></b></div> 
          <input class="input" maxlength="10" name="last" type="text" value="" size="30" /> 
        </div> 
        <div id="Uni"> 
         <div id="Diploma"><h3>Diploma:</h3></b></div> 
         <input type="radio" name="where" value="sv" size="30" /> sv 
         <input type="radio" name="where" value="sg" size="30" /> sg 
         <input type="radio" name="where" value="se" size="30" /> se 
         <input type="radio" name="where" value="lh" size="30" /> lh 
         <input type="radio" name="where" value="freshman" size="30" /> freshman 


         <div id="HighSchool"><b><h3>High School:</h3></b></div> 
          <input class="input" maxlength="10" name="hight" type="text" value="" size="30" /> 

的 「保證金左」 唐」 t在文憑和高中部門工作 我的代碼有什麼問題? 謝謝, 約翰尼拉

+0

「不工作」是什麼意思? –

+0

背景圖片未出現 –

+0

您確定圖片路徑正確嗎?你怎麼確定?確保它正確加載 –

回答

0

在你的CSS:

#Diploma { 
    margin-left: 400px; 
    font-size: 0.9em; 
    color: cornflowerblue; 
    border: 2px solid lime; 
    border-radius: 25px; 
    background-color: black; 
    margin: 20px; 
    width: 150px; 
    text-align: center; 
} 

margin: 20px覆蓋margin-left: 400px;這意味着在所有方向上緣20像素。如果您正在尋找快速解決方案,請在#FullName之後加上#Uni

#FullName, #Uni { 
    margin-top:10px; 
    margin-left:400px; 
} 

因爲我已經創建了一個fiddle here,如果能正常工作與我的形象的背景問題。如果您提供的HTML是您的所有HTML代碼,那麼您應該添加<body></body>標記。如果仍然無法正常工作,則必須在映像文件中出現問題,嘗試重新生成映像文件或使用其他文件。

順便說一句,你應該真正美化你的HTML/CSS代碼(至少縮進它)。

+0

評論不適用於擴展討論;這個對話已經[轉移到聊天](http://chat.stackoverflow.com/rooms/96621/discussion-on-answer-by-nostophilia-css-background-image-and-some-divisions-don)。 –

+0

@Nostophilia謝謝兄弟,我怎麼能在同一個地方顯示2張圖片,每3秒顯示一張,然後顯示第二張。我也想要一個這樣的過渡風格,比如淡入淡出或者推動或者像功率點一樣擦拭。非常感謝,Johny。 –

+0

@Nostophilia我對編程有點新,所以如果你能解釋這個jQuery的每一步,因爲我沒有理解它。我真的很煩,因爲很煩人。對於聊天部分,我不知道通知和標籤如何工作,如果您有任何想法,請在主持人的角度告訴我原因「評論不適合擴展討論」。我在這裏和聊天部分發布了這條消息,所以告訴我你在哪裏看到它。再次感謝。 –