css学习日记

css学习日记

css语法规范

构成:选择器+声明

h1{
 	list-style:none;
}

选择器

1.标签选择器:选择所有标签

2.类选择器://标签名字不能做类名

.bkground_top{
    color: red;
}

<p class = "bkground_top">
	妈耶
</p>

常用类命名规则

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HG986Pzt-1650984552825)(C:\Users\DELL\AppData\Roaming\Typora\typora-user-images\image-20220426211648732.png)]

多类名

一个标签内多个类名

<style>
.nav{
	font-size: 10px;
}
.color{
    color: red;
}
</style>
<body>
	<div class = "nav color"> zeze </div>
</body>

id选择器

“#”+选择器名

!!!只能调用一次!!! 一般与JavaScript结合使用

#name1{
	color: pink;
}

<p id = "name1"> lili </p>

*通配符选择器

“*”+选择器名

​ 选择页面内所有元素

* {
	margin:0;
	padding:0;
}    /* 通配符 删除浏览器默认值 */ 

一些属性

.content{
    width: 100px;
    height: 100px;
    background-color: red; //背景颜色
}

字体属性

.main{
    font-family: "微软雅黑";//宋体、黑体、隶书、楷体
	font-size: 20px;// 文字大小
    font-weight: bold/normal; // 字体粗细
    font-style: italic; // 设置字体样式 ,此处为倾斜
}
//

颜色属性

.color{
    color:red; // 预定义(测试)
    #FF0000; //16进制(常用)
    rgb(255,255,255);
}

文本属性

div{
    text-align: center/left/right;//居中左右对齐
    text-decoration:none/underline/overline/line-through // 无/下划线/上划线/删除线
    /*em 为相对单位 */
    text-indent:20px/2em(常用--当前两个文字距离); //首行缩进
    text-height:26px; // 行与行间的距离(包含上下间距)
}

css引入方式

1.行内样式表: 标签内部写

<p style = "color: red; font-size: 12px">
    ljj
</p>

2.内部样式表:将css代码放入

3.外部样式表

<link href = "路径" rel = "stylesheet" type = "text/css">

; font-size: 12px">
ljj

```

2.内部样式表:将css代码放入

3.外部样式表

<link href = "路径" rel = "stylesheet" type = "text/css">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值