Web前端-CSS必备知识点

Web前端-CSS必备知识点

css基本内容,类选择符,id选择符,伪类,伪元素,结构,继承,特殊性,层叠,元素分类,颜色,长度,url,文本,字体,边框,块级元素,浮动元素,内联元素,定位。

链接:

<link rel="stylesheet" type="text/css" href="sheet.css" title="default">
复制代码

link标签:

<link rel="stylesheet" type="text/css" href="sheet.css" title="default">
复制代码

样式:

h1 { color: red; };
复制代码

@import指示引入多个外部样式表的链接

<style type="text/css">
@import url(styles.css);
p { color: red };
</style>
复制代码

css注解

/* dashucoding */
复制代码

内联样式:

<p style="color: red;" >dashucoding</p>
复制代码

规范: 选择符 + 声明

p { color: red; } // 选择符 属性 值
复制代码
p { font-weight: bold; }
复制代码

伪类和伪元素

属性说明
:link超链接是一个未访问过的地址
:visited访问过的网页
:active处于活跃的状态
a { color: red; }; a:visited { color: red; };
复制代码

伪元素:

:first-letter  和  :first-line 首字母 和 首行
复制代码
p:first-letter { color: red; }
复制代码

css有个特点是继承,可以依赖于祖先-后代关系。

!important有这个标记,表示这条规则优先

p { color: red !important; }
复制代码

元素分类:

三种类型:块级元素,内联元素,列表项元素

块级元素有段落,标题,列表,表格,div,body等。内联元素有a,em,span等。列表项元素有li元素。

dispaly: block | inline | list-item | none
复制代码

颜色:

rgb(100%, 100%, 100%) 红蓝绿 ,白色
复制代码

单位:

em 给字体的font-size值
复制代码

文本: 文本缩进

text-indent <长度> | <百分比>
复制代码
p { text-indent: -4em; }
复制代码

text-align属性

用于元素中文本行的对齐方式
复制代码
text-align: left | center | right | justify
复制代码

white-space空白

white-space pre | nowrap | normal
复制代码
p { white-space: normal; } 将如何空白压缩成单个空白符
复制代码

white-space属性值为pre,可以将元素内的空白忽略。

p { white-space: pre; }
复制代码

行高:

line-height文本行的基线间的距离。

纵向对齐,vertical-align

vertical-align: baseline使元素的基线同父元素的基线对齐。

vertical-align: sub; vertical-align: super;
复制代码

低端对齐: vertical-align

顶端对齐:vertical-align

vertical-align: top; vertical-align: text-top;
复制代码

中间对齐:

vertical-align: middle;
复制代码

文字间隔:

word-spacing 长度 | normal
复制代码
word-spacing: 0.3em;
复制代码

字母间隔:

letter-spacing: 长度 | normal
复制代码

文本转换:

text-transform uppercase | lowercase | capitalize | none
复制代码

文本修饰:

text-decoration: none | overline | line-through
复制代码

框:

width 长度 | 百分比 | auto
height 长度 | auto
margin 长度 | 百分比 | auto
margin: top right bottom left
margin-top
margin-right
margin-bottom
margin-left

border-width // thin medium thick
border-style: none;

padding
复制代码

浮动与清除

float: left | right | none
复制代码
<img src="" style="float: right"; alt="dashu">
复制代码
float: none 用于防止元素浮动
复制代码

清除浮动元素

clear left | right | both | none
复制代码

clear原理是增加元素的上边界,使它在低于浮动元素的位置结束,清除元素的上边界宽度当有效地忽略。

list-style-type disc

disc | circle | square | decimal | upper-alpha | lower-alpha | upper-roman | lower-roman | none

list-style-type
disc 为实心圆
circle 为空心圆
square 实心或空心方块
复制代码

列表项图像

list-style-image <url> | none
复制代码

列表项位置:list-style-position

list-style-position: inside | outside
复制代码

定位:

position: static | relative | absolute | fixed | inherit
复制代码

溢出:

overflow: visible | hidden | scroll | auto | inherit
复制代码

溢出剪切:

overflow-clip: rect | auto | inherit
复制代码

元素剪切:

clip rect | auto | inherit
复制代码

元素可见性:

visibility: visible | hidden | collapse | inherit
复制代码

相对定位:

position: relative;
复制代码

绝对定位:

position: relative;
复制代码

固定定位:

position: fixed;
复制代码

层叠定位:

z-index: integer | auto
复制代码

轮廓:

outline, outline-color, outline-style, outline-width
复制代码

边框:

border-top-color, border-right-color, border-bottom-color

border-left-color, border-top-style
border-right-style, border-left-style
复制代码

实例:

<table cellspacing=0 border cellpadding="10">
 <tr>
  <td rowspan=2>dashu</td>
  <td colspan=2>dashu2</td>
 </tr>
 
 <tr>
   <td>1</td>
   <td>2</td>
 </tr>
</table>
复制代码

结言

好了,欢迎在留言区留言,与大家分享你的经验和心得。

感谢你学习今天的内容,如果你觉得这篇文章对你有帮助的话,也欢迎把它分享给更多的朋友,感谢。

作者简介

达叔,理工男,简书作者&全栈工程师,感性理性兼备的写作者,个人独立开发者,我相信你也可以!阅读他的文章,会上瘾!,帮你成为更好的自己。长按下方二维码可关注,欢迎分享,置顶尤佳。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值