css的基础应用

1、基础知识

CSS定义:cascading style sheet 层叠样式表。

语法:
选择器 {
属性名1:属性值1;
属性名2:属性值2;
属性名3:属性值3;
属性名4:属性值4;
}

CSS使用:
1、通过选择器选择上标签
2、在选择的标签上设置样式

选择器分类:
标签选择器: p{}
类选择器: .className{}
id选择器: #id{}

一些常见的样式:
color:red; 文字颜色
font-size:40px;
background-color:blue;
text-decoration:underline;
text-decoration:none; //去掉下划线

2、css简单应用

.yellow{
	color: yellow;
}
.red{
	color: red;
}

.big-font{
	font-size: 50px;
}
.underline{
		text-decoration: underline;
}
#green{
	color: green;
}

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../css/my.css" />
		<style type="text/css">
		.blue{
			color:blue;
		}
	
		
		</style>
	</head>
	<body>
		<h1 class="yellow                                                                   ">周老师</h1>
		<h1 class="blue underline">朱老师</h1>
		<h1 class="red big-font underline" >高老师</h1>
		<h1 id=green>洪老师</h1>
		
		
		
	</body>
</html>

在css中定义的.yellow .big-font,可以通过class="?"来调用,可以在class中调用多个css以达到自己要求的格式。

3、盒模型

盒子中主要的属性就5个:width、height、padding、border、margin。
padding:内边距 margin:外边距
div{
width: 200px;
height: 200px;
padding-left: 10px;
padding-right: 20px;
padding: 40px 50px 60px; // 上右下左(顺时针方向,某一个方向没写就取对边的值)
padding-bottom: 30px;
/border: 8px solid #000000;/
border: 8px solid #000;

}在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值