开发者

Crazy problems with HTML and stylesheets: stuff is showing up that I didn't even write

开发者 https://www.devze.com 2023-02-28 12:55 出处:网络
This problem is incredibly hard to describe.I feel like I\'ve entered the twilight zone.However, I\'m new to HTML and CSS, and there\'s a great chance I\'m doing something completely wrong.

This problem is incredibly hard to describe. I feel like I've entered the twilight zone. However, I'm new to HTML and CSS, and there's a great chance I'm doing something completely wrong.

I have multiple files in a folder, amongst them are: style.css, homePage.html, and addPerson.php

I'm intending style.css to be an external style sheet to handle both pages. I wrote addPerson.php first and had no problems getting it to work with the external stylesheet. However, once I added the homePage.html file (which is linked to on the addPerson.php webpage), I'm having all sorts of crazy problems. On the left of the page of my addPerson.php page, there is an unordered list of links, stuck on the left using "float". In my homePage.html file, I want to have this same exact list. Thus, I copied and pasted the code into that file. Here's what that code looks like:

<body>
    <div class="Links">
    <p>
    Add new content:
    <ul>
    <li><a href="addComments.php">Add comments to movies</a></li>
    <li><a href="addMovieInfo.php">Add movie information</a></li>
    </ul>
    Browse content:
    <ul>
    <li><a href="showActorInfo.php">Actors</a></li>
    <li><a href="showMovieInfo.php">Movies</a></li>
    </ul>
    Search:
    <ul>
    <li><a href="searchActorsOrMovies.php">Search</a></li>
    </ul>
    </p>
    </div>

Here's what the "Links" class, from st开发者_C百科yle.css looks like that was referenced:

.Links
{
float: left;
background-color:#E6E6E6;
height: 522px;
}

That piece of code makes it so that there's a list of links with a grey background that runs down the left side of the page. It works just fine in addPerson.php. Here's a screenshot of that file: http://i1126.photobucket.com/albums/l610/cpatton1027/Screenshot2011-04-25at104256PM.png?t=1303796942

However, when I copy and paste that piece of code into homePage.html, I find that it doesn't work. Rather, the class reference doesn't do a thing. It just shows up as an unordered list of links, without the grey background or anything. Thus, homePage.html looks like this: http://i1126.photobucket.com/albums/l610/cpatton1027/Screenshot2011-04-25at104311PM.png?t=1303796993

Thinking that was a little weird, I ran a few tests on homePage.html. I cut down the code to just this:

<body>
    <div class="Links">
    <p>
    Add new content:
    <ul>
    <li><a href="addComments.php">Add comments to movies</a></li>
    <li><a href="addMovieInfo.php">Add movie information</a></li>
    </ul>
    </p>
    </div>
</body>

However, I find that when doing this, things got very strange! Here's a picture: http://i1126.photobucket.com/albums/l610/cpatton1027/Screenshot2011-04-25at104341PM.png?t=1303797030

That makes no sense at all to me.

I then cut the code down even further, to:

<body>
    <div class="Links">
    <p>
    Add new content:
    <ul>
    <li><a href="addComments.php">Add comments to movies</a></li>
    </ul>
    </p>
    </div>
</body>

Now with this change, it suddenly looked correct. The grey background was there, and the rest of the text was not. Here is what that looked like: http://i1126.photobucket.com/albums/l610/cpatton1027/Screenshot2011-04-25at105119PM.png?t=1303797106

What the heck is going on? Why is the Links class working perfectly in my initial file but horribly in this new file I'm creating? (note: there are a bunch of other weird things that has happened in trying to figure this out, but since I've already written a novel I decided to just slim it to this problem).


I wonder if this was a caching problem? Browsers tend to cache pages rather than going back to the server to fetch them...if you're updating a page frequently, remember to press Ctrl + F5 to clear the cache and completely re-fetch the page, or else you might think your changes aren't getting saved.

If you put the text back in, does homePage.html revert to the non-working version?

EDIT: Also, of course, it might be a problem with the server not having the right version of the code you are expecting it to have. If you view the source and see that it doesn't have the HTML you expect it to have, then you'll need to make sure you are making a request to the right place, and that that place has the right code. This includes HTML, PHP, and CSS pages.


It might help to set your doctype.

0

精彩评论

暂无评论...
验证码 换一张
取 消