Loading

HTML 引用Css样式的四种方式

不才,只知道HTML引用CSS样式有四种方式,内部引用和外部引用各两种,因为老是忘记细节,记下了随时翻阅亦可方便如我般的初学者

内部引用方式1:

   直接在标签内用 style 引用,如:

<div class="pmc" style="border:1px solid #440000;padding=0px;margin:40px;"> </div> 

内部引用方式2:

  在页面头文件的<style></style>标签里引用,如:

如此话,style 标签最好放到<head>标签里面,不过我试过没放进去也是可以的
<head>
<style type="text/css">
		
	body{padding:50px;margin:20px;padding:0px;background:#ffffff;line-height:21px}
	.pmc{margin:10px; padding:8px 0px 10px 5px; height:auto; border-bottom:1px solid #e8e5e5;}
	.pmc .title{ padding-bottom:5px;}
	.pmc .pic{ width:78px; height:100px; float:left; border:1px solid #ff0000; }
	.pmc .price{ padding:17px 0px 0px 20px; float:left; color:#ca0000;}
	.pmc .price.title{ padding-bottom:5px;}
	
	#test{border:1px solid #440000; width:200px;height:100px;}
</style>
</head>

外部引用方式1:

  用<link>标签,如:

注意:不要放到页面头部的<style>标签里面,且href可不转义:即<pre name="code" class="html">href="D:\learn\css.css" =》 href="D:\\learn\\css.css"
<link REL="STYLESHEET" type="text/css" href="D:\learn\css.css" />


外部引用方式2:

  用@import 方式,如:

 注意:这种方式一定要放到<style></style>里面,并且一定要用转义:即 url("D:\\learn\\css.css") 只能这样,不能 url("D:\learn\css.css")
@import url("D:\\learn\\css.css");

顺便说一声:id比clas优先

以上均为个人经验,仅供参考!



posted @ 2014-07-02 15:29  乔达摩(嘿~)  阅读(358)  评论(0编辑  收藏  举报