淘先锋技术网

首页 1 2 3 4 5 6 7

一旦我把我的HTML代码FTP到服务器上,我就很难链接到我的CSS代码。CSS文件和HTML文件都在服务器上的同一个目录中。我想指出的是,我已经尝试清除浏览器缓存,并使用不同的浏览器,似乎没有工作。

以下是我的HTML代码:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <base href="http://people.rit.edu/~username/rop/" target="_blank">
        <title> My ROP Home Page </title>
        <link href= "style.css" type="text/css" rel="stylesheet">
    </head>
    <body>
        <div class = "things">
                <h1> All About Me </h2>
            <div id = "activities">
                <h2> I'm a fan of video games </h2>
                    <p> As the title suggests, I love to play video games.  I have been playing video games since I was 8 years old.  I started with a Nintendo 64 and have since then begged my parents for every new system to date (obviously that wont work anymore).
                        This hobby is part of the reason I wish to become a web developer.  When I was young, I spent time browising websites like IGN, and thought that one day I could make something like that.  Now I set my sights a little higher, seeing as I want to be able to develope professional websites.
                    </p>
                <h2> My Favorite Food is Pizza ( I Can't get enough!) </h2>
                    <p> Seriously, I could have Pizza everyday of the week and not get sick of it.  I like all kinds of toppings except pineapple.  I must have pizza at least once a week no matter how unhealthy that may be.  Of course, local buisnesses make better pizza then large chains.
                    </p>
                <h2> I am a SOIS student focusing on Web Development and other IT centered courses</h2>
                    <p> SOIS is the School of Individualized Study.  Basically I create a major that is more in line with what I want to get out of R.I.T.  Students of SOIS must pick two specializations in order to create a degree.  Other than that, it is just like other degrees at R.I.T with many of the same requirments.
                        For example, I specialize in Web Development (front-end) and some networking.
                    </p>
                <h2> I'm a Big Fan of cheesey monster movies </h2>
                <p> For reasons unknown, I have been drawn to old Godzilla movies that clearly have not aged well.  I think it's neat to see how they made those films without cgi or technology.  Seeing the behind the scenes of the mini cities is always a neat experience for film fans.
                </p>
            </div>
        </div>
        <div id = "brian">
        <img src ="brian.jpg" alt="brian" style="width:304px;height:228px;">
        </div>
    </body>

</html>

CSS代码

h1, h2, p{
    background-color: #100733;
}
title {
    font-family: Helvetica, Arial, sans-serif;
    text-align: center;
    text-transform: uppercase;
}

.things     {
    color: white;
    font-size: 18px;
}
#brian {
    float: right;
}
#activities {
    font-size: 18px;
    text-align: left;
}

p {
    background-color: #100733;
    color: white;
}

任何帮助都将不胜感激。

# # #难道你忘了开场& lt在第一行(Doctype)?

让它& lt!DOCTYPE html & gt并确保style.css文件与索引文件在同一个目录中。

编辑:

未发现

在此服务器上找不到请求的URL /~username/rop/

people.rit.edu 443端口的Apache服务器

所以它不能工作是因为base标签。您确定提供的位置有效吗?当我打开https://people.rit.edu/~username/rop/时,它给出443。

编辑2:

改变:

& ltbase href = " http://people . rit . edu/~ bxa 9985/ROP/" target = " _ blank " & gt;

收件人:

& ltbase href = " https://people . rit . edu/~ bxa 9985/ROP/" target = " _ blank " & gt;

# # #首先

确保您可以使用浏览器访问css文件。

如果你的url是,比如说example.com,你像example.com/index.html,这样访问你的html文件,那么确保如果你进入example.com/style.css,你确实能看到css

如果你通过ftp上传文件,可能是你没有在服务器上设置权限。

然后是其他考虑

确保您有第一个开始字符& lt

看到这个了吗

!DOCTYPE HTML>

应该是这样的

<!DOCTYPE HTML>

去掉等号(=)前后的空格

<link href= "style.css" type="text/css" rel="stylesheet">

应该是这样的

<link href="style.css" type="text/css" rel="stylesheet">

# # #看,这可能是愚蠢的,但它可能是你的css文件名在html文件中不匹配,我面临这个问题,我的解决方案是我把Style.css中的“S”从大写改为小写,为我工作。