简体   繁体   English

如何在sublimetext 2中将CSS文件与html链接?

[英]How can I link my css file with my html in sublimetext 2?

我的主要疑问是href的一部分。如何避免使用保存在硬盘中的文件的完整链接,以便在通过ftp传输时不需要更改它。我也想知道如何查看html文件已开发,已链接到您的桌面网络浏览器(例如chrome)上的不同css文件。

If your HTML file is stored in a directory, and your CSS files are stored, for example, in a css subdirectory, all you need to do is add 如果您的HTML文件存储在目录中,而CSS文件存储在例如css子目录中,则只需添加

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

to the <head> tags of your HTML file, and you'll be all set. 到HTML文件的<head>标记中,便一切就绪。

If the file is in the same folder as your HTML file you will simply type the name of the file 如果文件与HTML文件位于同一文件夹中,则只需输入文件名

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

Let's say that your style.css file is in another folder called css 假设您的style.css文件位于另一个名为css的文件夹中

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

By playing a "/" in front of your file name it is saying that it should look for the "css" folder starting from the root folder instead of the current location. 通过在文件名前面播放“ /”,表示它应该从根文件夹而不是当前位置开始寻找“ css”文件夹。

You can use relative paths. 您可以使用相对路径。 If the css stylesheet is in the same folder as the html use href="style.css". 如果css样式表与html位于同一文件夹中,请使用href =“ style.css”。 If it's in a folder that is in the same folder as the html use href="styles/style.css". 如果位于与html相同的文件夹中,请使用href =“ styles / style.css”。 If you need to go up a folder use href="../style.css". 如果您需要上一个文件夹,请使用href =“ ../ style.css”。

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

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