CSS样式(基础)

一、CSS语法
在这里插入图片描述
二、CSS添加方法
1.CSS添加方法——行内

<p style="color:red;">
天使投资指早期投资,尤其指个人早期投资
</p>

2.CSS添加方法——内嵌样式

<!DOCTYPE HTML>
<html>
<head>
<title>abc</title>
	<meta charset="utf-8">
     <style type="text/css">
     	p{
     		color:red;/*设置字体颜色*/
     	}
     </style>
      </head>
      <body>
      <p>天使投资指早期投资,尤其指个人早期投资</p>
      </body>
      </html>

注意
在这里插入图片描述
3.CSS添加方法——单独文件

<!DOCTYPE html>
<html>
<head>
<title>abc</title>
	<meta charset="utf-8">
     <link rel="stylesheet"  href="css/style.css">
      </head>
      <body>
      <p>天使投资指早期投资,尤其指个人早期投资</p>
      </body>
      </html>

其优点为
在这里插入图片描述
4.CSS添加方法——优先级
在这里插入图片描述
三、CSS选择器
1.标签选择器

<style type="text/css">
body{background-color :#ccc;  /*背景色为灰色*/
text-align:center;
font-size:12px;
}
h1{font:"黑体";font-size:20px;}
p{color:red;font-size:16px;}
hr{wideth:200px;}
</style>

2.类别选择器

<style type="text/css">
p{font-size:12px;}
.one{font-size:18px;}
.two{font-size:24px;}
 </style>

在对应的标签之内,采用他的class属性来进行类别样式的引用,给它设置的属性的取值,就是类别样式的名称,并且注意点需要去掉。

<body>
<p class="one"> 类别1 </p>
<p class="one"> 类别1 </p>
<p class="two"> 类别2 </p>
<p class="two"> 类别2 </p>
<p>普通段落中的文字 </p>
</body>

3.ID选择器(在html里只能唯一被引用一次)
css样式

<style type="text/css">
    #one{font-size:12px;}
  #two{font-size:24px;}
     </style>

样式的引用

<body>
<p id="one"> 文字1</p>
<p id="two"> 文字2</p>
</body>

4.集体声明

 <style type="text/css">
   h1,p{text-align;center;}
         </style>

5.全局声明

  <style type="text/css">
       *{text-align;center;}
             </style>

6.混合
在这里插入图片描述
四、CSS样式之文字样式

1.单位
在这里插入图片描述
2.颜色
在这里插入图片描述
3.文本
在这里插入图片描述
(1).字符间距letter-spacing

  <style>
       h1{letter-spacing:2px;}
    h2{letter-spacing:-3px;}
    </style>

(2).行高 line-height

   <style>
     p{font size:14px;
       line-height:2em;}
</style>

(3).对齐方式text-align

<style>
h1{text-align:center}
.date{text-align:right}
.main{text-align:justify}
</style>

(4).装饰线 text-decoration

    <style>
    h1{text-decoration:overline}
   h2{text-decoration:line-through}
   h3{text-decoration:under-line}
    </style>

4.字体
在这里插入图片描述
五、CSS样式之背景,超链接样式
1.背景属性
在这里插入图片描述2.超链接
在这里插入图片描述鼠标悬停放大字体

a{font-size:22px;
}
a:hover{font-size:120%;
}

六、CSS样式之列表,表格样式
列表
1.list-style-type
在这里插入图片描述2.list-style-position

<style type="text/css">
   .inside{
   list-style-position:inside
   }
    .outside{
   list-style-position:outside
   }
   </style>

3.list-style-image

list-style-image:
url("images/bullet1.gif");

4.表格
在这里插入图片描述在这里插入图片描述
5.奇偶选择器:nth-child(odd|even)

tr:nth-child(odd){
background-color:#EAF2D3;}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值