当前位置: 首页 > 网络学院 > 网页制作基础教程 > WEB设计综合 > 链接至外部样式表
The advanced way, and the easiest way to do CSS is to link to an external style sheet. Here I will sow you how. If you are new to CSS, I reccommend reading the basic CSS tutorial first.
更高级、更方便的方式就是链接到一张外部的样式表。在这里,我将告诉你具体的操作方法。如果你刚刚接触CSS,那么我建议你想学习一下基础的CSS教程。
First, open up notepad and put all your styles in. One of the great things about external style sheets is that you don't have to put in the <style> tags, just the code that normally goes in between them.
首先,打开记事本,然后把所有的样式代码放置其中。最能体现外部样式表优势的地方就是:你不需要放置<style>标签,然后在这个标签内部书写代码。
Put all the code in that you want, but it might be best to just start with something like this:
把所有的代码放置其中,建议一下面这样的方式开头:
body{font-color:#CCCCCC} |
Got that? Go to file-->save as and save the file as style.css It must have the .css extension, otherwise it won't work.
明白了?然后点击“文件”—“另存为(将文件存储为style.css)”,该文件必须以.css结尾,否则将失效。
Open up the file that you wish to apply the style to, and put this into the <head> </head> tags of the page:
打开你希望应用样式表的文件,将它放置到<head></head>标签中:
<link rel="stylesheet" href="style.css"> |
If you gave your .css file a different name, you will have to change it in the code above. 如果你为.css文件定义了一个不同的名称,你需要对上面的代码进行更改。
That is all there is to it! 完毕!