2015-07-10 43 views
0

我在Mac機器上的NetBeans IDE ver 8.0.2中創建了一個HTML文件和一個要從外部引用的CSS文件。外部CSS在Webhost提供程序中無法運行

雖然它在桌面上以編碼方式工作,但將它上傳到我的託管服務提供商的public_html文件夾中,這些樣式只能部分應用。

例如,名爲'logo1'的內部容器沒有右對齊。

PS:我知道我下面粘貼的那段代碼會導致內部容器中的文本溢出。請讓它不要分心。

我的HTML代碼列舉如下:

<!DOCTYPE html> 
 
    <!-- Home Page for Project 01 --> 
 
    <html> 
 
    <head> 
 
     <meta charset="UTF-8"> 
 
     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
     <title> Project 01 - Key to your Technological Superiority </title> 
 
     <link rel="stylesheet" type="text/css" href="commonstyles.css" /> 
 
    </head> 
 

 
    <body> 
 
     <div class="container1"> 
 
      <div class="logo1"> 
 
      <!-- &#0169 is the code for the Copyright symbol --> 
 
       <h1> Project 01 <sup>&#0169</sup></h1>  
 
      </div> 
 
      <div class="footer1"> 
 
       <b> BIGGER BRIGHTER BETTER</b> 
 
      </div> 
 
     </div> 
 
    </body> 
 
    </html>

我的CSS代碼如下所示:

div.container1 { 
 
    position:relative; 
 
    top: 0; 
 
    left: 0; 
 
    width: 600px; 
 
    height: 100px; 
 
    background-color: rgba(255,255,255,0.0); 
 
    border: none; 
 
} 
 

 
div.logo1 { 
 
    position:absolute; 
 
    top: 10px; 
 
    right: 0; 
 
    width: 300px; 
 
    height: 45px; 
 
    background-color: rgba(57,29,75,1.0); 
 
    color: white; 
 
    text-align: center; 
 
    font-family: Arial;     
 
} 
 

 
div.footer1 { 
 
    position:absolute; 
 
    top: 60px; 
 
    left: 150px; 
 
    font: Times New Roman; 
 
    font-variant: all-small-caps; 
 
}

回答

0

是個e CSS文件正確加載,即你檢查路徑?在這個小提琴中,代碼似乎工作。

div.logo1 { 
    position:absolute; 
    top: 10px; 
    right: 0; 
    width: 300px; 
    height: 45px; 
    background-color: rgba(57,29,75,1.0); 
    color: white; 
    text-align: center; 
    font-family: Arial;     
} 

https://jsfiddle.net/1eyqtm18/

+0

嗯,這是最令人困惑的部分。除了加載到我的文件管理器中時,它可以在任何地方使用在我的桌面上,HTML和CSS文件都在同一個文件夾中。到現在爲止還挺好。但是,將它們上傳到** SAME **文件夾到我的託管服務提供商的文件管理器中時,奇怪的事情正在發生。例如正如代碼段中所提到的,「Project 01」這個措辭正在獲得一個bgcolor,但沒有得到正確的理由。過去2-3天有點厭倦了這一點。 –