怎么在html5中加入css样式

html-css011

怎么在html5中加入css样式,第1张

HTML5使用link引入外部css

<head>

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

</head>

style.css/外部css文件名

html5 css3样式图标制作方法:

1、html代码:

<div id="boxes">

<div id="boxShortcode">border-radius: 40px (shortcode)</div>

<div id="box1">border-top-right-radius: 40px (same on both axis)</div>

<div id="box2">border-top-right-radius: 20px 40px (x <y) </div>

<div id="box3">border-top-right-radius: 40px 20px (x >y) </div>

</div>

2、css样式代码:

#boxes div { margin-bottom: 20pxheight: 50pxpadding-left: 20px }

#boxShortcode {

background: cyan

border-radius: 40px

}

#box1 {

background: red

border-top-right-radius: 40px

}

#box2  {

background: yellow

border-top-right-radius: 20px 40px

}

#box3 {

background: lime

border-top-right-radius: 40px 20px

}

3、运行结果:

html中,有的css样式在样式表里不起作用是设置错误造成的,解决方法为:

1、在如图网页中,我们可以看到style中的样式列表,以及所展示的效果图。

2、将style中的全部css样式选中,然后复制或者剪切。

3、然后ctrl+N新建一个CSS样式文件,如图所示,然后创建。

4、在创建的css样式文件中,将刚才复制的文件粘贴到这里。

5、在导出时,需要放到之前网页所在的同文件夹位置,可以新创建一个css文件夹,方便寻找导入。

6、然后回到html文件中,将之前的style样式全部删除即可,然后输入link链接标签,将之前保存的css样式链接进来,保存。