简体   繁体   English

我的CSS除网站上的一页外不起作用

[英]My CSS doesn't work, except for one page in my website

I just started learning webdesign and I'm having this ongoing problem and I've posted a question about it before. 我刚刚开始学习网页设计,并且遇到了这个持续存在的问题,之前我已经发布了一个关于它的问题。 Everything I tried didn't work but I made a few changes so I wanted to rephrase the question and add some more details. 我尝试的所有内容均无济于事,但我进行了一些更改,因此我想重新表述该问题并添加更多详细信息。

I'm making a simple website for a Romanian artist and it will have an English version and a Romanian version (switching languages with tiny flags in the nav bar). 我正在为罗马尼亚艺术家制作一个简单的网站,它将有英文版本和罗马尼亚版本(在导航栏中切换带有小标志的语言)。

It's all written in WordPad, using just html and css, and all pages are in the same root folder. 它们全部用写字板编写,仅使用html和css,并且所有页面都位于同一根文件夹中。 I have several html files and one css file (so it's an external file), which is linked in the head of each page. 我有几个html文件和一个css文件(因此它是一个外部文件),该文件链接在每个页面的开头。 I have English versions and Romanian versions and they're all linked accordingly from the navigation. 我有英文版和罗马尼亚文版,它们都从导航中进行了相应链接。

Now, my issue is that the CSS will only work on the main English page and refuses to on any of the others, no matter which language, despite all of them having the same head, header and footer structure. 现在,我的问题是,尽管所有CSS具有相同的页眉,页眉和页脚结构,但CSS只能在主要的英语页面上工作,并且拒绝在其他任何语言上使用。

I tried Firefox and Chrome and it's the same story. 我尝试使用Firefox和Chrome,这是同一回事。

I clicked on "Page Source" on all the pages when opened in a browser, corrected any errors showing up, and the link to the css and all pages works when I click it. 在浏览器中打开时,我单击了所有页面上的“页面源”,更正了显示的所有错误,并且单击CSS和所有页面的链接都可以使用。

I initially had several CSS files, one for each html file, but I deleted them except for one (I misunderstood the process initially and didn't realize they can all have the same css file). 我最初有几个CSS文件,每个html文件一个,但是我删除了它们,除了一个(我误解了这个过程,没有意识到它们都可以有相同的css文件)。 So now there is only one CSS file in the root folder "Style.css". 因此,现在根文件夹“ Style.css”中只有一个CSS文件。

All html files are saved in "Unicode" encoding. 所有html文件均以“ Unicode”编码保存。

Except for the modified words, this is the exact css, as well as html structure of the main English page (on which the CSS works): 除了修改的单词,这是确切的css,以及主要英语页面(CSS可以在其上工作)的html结构:

 h1 { display: inline-block; font-family: Tahoma; } nav { display: inline-block; float: right; font-family: Tahoma; } address { float: right; } article.figures figure { display: inline-block; float: left; } aside { float: right; Font-family: Verdana; } footer { color: grey; font-family: Tahoma; float: left; } 
 <!DOCTYPE html> <html> <head> <title>Name</title> <LINK rel="stylesheet" type="text/css" href="style.css"> <meta charset="utf-8"> <meta name="description" content="Name, visual artist"> <meta name="keywords" content="Name, visual artist, abstract, painting, fine art"> <meta name="author" content="Me"> </head> <body> <header> <img src="images\\paint logo.jpg" width="150" height="110" alt="artists logo"> <h1>Name </h1> <nav> <a href=///C:/Users/.../main page in English.html>Galleries</a> <a href=file:///C:/Users/.../News.html>News</a> <a href=file:///C:/Users/.../About.html>About</a> <a href="http://www.saatchiart.com/...">Shop</a> <a href="file:///C:/Users/.../webpageinRomanian.html"> <img src="images\\romanian flag.jpg" width="20" height="15" alt="Romanian"> </a> </nav> </header> <address>email</address> <article class="figures"> <figure> <img src="images\\painting.jpg" width="335" height="325" alt="painting"> <figcaption>Paintings from 2010 - 2015</figcaption> </figure> <figure> <img src="images\\2.jpg" width="335" height="325" alt="painting 2"> <figcaption>2009 - 2000</figcaption> </figure> <figure> <img src="images\\3.jpg" width="335" height="325" alt="painting 3"> <figcaption>1990 - 1999</figcaption> </figure> </article> <footer>copyright Name <br> <A HREF="https://www.facebook./..."> <IMG SRC="images/fb logo.png" width="30" height="30" ALT="Facebook"> </A> <A HREF="https://www.behance...."> <IMG SRC="images/behance logo.png" width="30" height="30" ALT="Behance"> </A> <br>Webdesign by me </footer> </body> </html> 

This is a page on which the same CSS doesn't work: 这是同一CSS无法使用的页面:

 h1 { display: inline-block; font-family: Tahoma; } nav { display: inline-block; float: right; font-family: Tahoma; } address { float: right; } article.figures figure { display: inline-block; float: left; } aside { float: right; Font-family: Verdana; } footer { color: grey; font-family: Tahoma; float: left; } 
 <!DOCTYPE html> <html> <head> <title>Name News</title> <LINK rel="stylesheet" type="text/css" href="style.css"> <meta charset="utf-8"> <meta name="description" content="Name, visual artist"> <meta name="keywords" content="Name, visual artist, abstract, painting, fine art"> <meta name="author" content="Me"> </head> <body> <header> <img src="images\\paint logo.jpg" width="150" height="110" alt="artists logo"> <h1>Name </h1> <nav> <a href=///C:/Users/.../main page in English.html>Galleries</a> <a href=file:///C:/Users/.../News.html>News</a> <a href=file:///C:/Users/.../About.html>About</a> <a href="http://www.saatchiart.com/...">Shop</a> <a href="file:///C:/Users/.../webpageinRomanian.html"> <img src="images\\romanian flag.jpg" width="20" height="15" alt="Romanian"> </a> </nav> </header> <address>email</address> <h2>What's New</h2> <h3>Upcoming exhibitions:</h3> <ul> <li>July 2016</li> <li>October 2016</li> </ul> <footer>copyright Name <br> <A HREF="https://www.facebook./..."> <IMG SRC="images/fb logo.png" width="30" height="30" ALT="Facebook"> </A> <A HREF="https://www.behance...."> <IMG SRC="images/behance logo.png" width="30" height="30" ALT="Behance"> </A> <br>Webdesign by me </footer> </body> </html> 

Which might work on this website, but I swear, it won't work in my browsers. 在该网站上可能可以使用,但我发誓,在我的浏览器中无法使用。

It's driving me nuts. 它让我发疯。

I'd be extremely grateful for any help! 我将非常感谢您的帮助!

EDIT: This is what shows up in the developers console for the 'News' page: 编辑:这是开发人员控制台中“新闻”页面上显示的内容: 在此处输入图片说明

在此处输入图片说明

And this is the root folder: 这是根文件夹: 在此处输入图片说明

Try this inside your <head> <head>内部尝试

Source: w3schools 资料来源:w3schools

 <base href="http://www.yourwebsite/" target="_blank"> 

Well it is working for me... make sure that the html and css files actually are in the same folder 好了,它对我有用...确保html和css文件实际上位于同一文件夹中

/folder
--thing.html
--other.html
--style.css

And as pointed out in comment don't use c:/ to referer to files 并且如注释中所指出的,不要使用c:/来引用文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM