CSS/CSS3语法新特性笔记
CSS层叠样式表
三大特性
层叠性:相同的样式会覆盖
继承性:属性可向下继承
优先级:范围越小权重越高
选择器
基础选择器
标签选择器
1 body {
2 color:#fff;
3 }
类选择器
1 .people‐first {
2 color:green;
3 }
id选择器
1 #laowang {
2 color:yello;
3 }
通配符选择器
* {
2 margin: 0 ;
3 padding: 0 ;
4 }
高级选择器
后代选择器
1 ul li {
2 list‐style;none;
3 }
子选择器
1 h3>a {
2 line‐height:36px;
3 }
并集选择器
1 div,
2 p {
3 font‐size:14px;
4 }
伪类选择器
1 a::hover {
2 background‐color:springgreen;
3 }
a::link
a::visited
a::hover
a::active
input::focus
相邻兄弟选择器
h1 + p {
margin-top:50px
}
font属性
1 font‐style:italic;
2 font‐weight: 400 ;
3 font‐size:16px;
4 font‐family:"Microsoft Yahei";
5 font:italic 400 16px "Microsoft Yahei";
字体图标的下载与使用
text属性
1 color:pink;
2 text‐align:center;
3 text‐decoration:none;
4 text‐indent:2em;
5 line‐height:26px;
块元素
例如h p div ul li
- 独占一行
- 宽 高 内外边距 可控
- 宽度默认继承
- 主要作为容器
行内元素
例如 a strong b em
- 一行可以是多个
- 宽高无法设定
- 默认宽度为自身宽度
- 很内元素只能容纳文本或其他行内元素
注:连接标签里不能放链接
注:链接里可放块级元素,但最好把a转换成块级元素安全
行内块元素
例如 img input td
- 可以一行多个(有缝隙)
- 可以设置宽高
- 宽度为默认
- 元素显示模式转换
1 display:block;
2 display:inline;
3 display:inline‐block;
background背景
1 background‐color:transparent;
2 background‐img:url(./xx);
3 background‐repeat:repeat | no‐repeat | repeat‐x | repeat‐y;
4 background‐position:center center;
5 background‐attachment:scroll | fixed;
6 background:pink url(./) no‐repeat fixed center top;
1 background‐size:500px 200px;//cover等比完全覆盖,contain等比宽高覆盖
精灵图的具体操作与使用
盒子模型
border or margin
1 border‐width:5px;
2 border‐style:solid; // dashed(虚线) dotted(点线)
3 border‐color:black;
4
5 border:5px solid black;
1 margin:0 auto;//可使盒子水平居中
2 margin‐left:‐1px;//用于消除紧挨着的边框
border-collapse
border-collapse: collapse;
border collapse 属性设置表格的边框是否被合并为一个单一的边框,还是象在标准的
HTML 中那样分开显示。
圆角边框
1 border‐radius:10px;
2 border‐radius:1px 2px 3px 4px;//右上角开始
3 border‐top‐left‐radius:...;
盒子阴影
1 box‐shadow: 10px 10px 5px ‐5px rgba(0,0,0,.3);
2 水平阴影 垂直阴影 [模糊 尺寸 颜色 外部或内部]
文字阴影
1 text‐shadow:10px 10px 5px rgba(0,0,0,.3);
float浮动
1 float:left;
浮动特性:
脱离标准流
一行显示,顶部对齐
具备行内块的特性
清除浮动
1 . 额外标签法
1 <div>
2 <div>盒子</div>
3 <div class="clearfix"></div>
4 </div>
1 .clearfix {
2 clear: both;
3 }
2 . 父级添加overflow
1 <div class="clearfix">
2 <div>盒子</div>
3 </div>
1 .clearfix {
2 overflow:hidden;
3 }
3 . :after伪元素
1 <div class="clearfix">
2 <div>盒子</div>
3 </div>
1 .clearfix::after {
2 content: "";
3 display: block;
4 height: 0 ;
5 clear: both;
6 visibility: hidden;
7 }
8
9 .clearfix {
10 *zoom: 1 ;
11 }
4 . 双伪元素清楚浮动
1 <div class="clearfix">
2 <div>盒子</div>
3 </div>
1 .clearfix:before,
2 .clearfix::after {
3 content: "";
4 display: table;
5 }
6
7 .clearfix::after {
8 clear: both;
9 }
10
11 .clearfix {
12 *zoom: 1 ;
13 }
定位
静态定位(了解)
1 position:static;
相对定位
1 position:relative;
绝对定位
1 position:absolute;
固定定位
1 position:fixed;
粘性定位(了解)
1 position:stycky;
边偏移
top
bottom
left
right
优先级
1 z‐index:2;
元素显示与隐藏
显示模式
1 display:block | inline | none ;
2 块级 行内 无
可视能力
1 visibility:inherit | visible | hidden;
2 继承 可视 隐藏
溢出部分
1 overflow:visible | hidden | scroll | auto;
2 不剪切,不加滚动条 隐藏 滚动条 自动
用户界面样式
鼠标样式
1 cursor:default;
1 cursor:pointer;
1 cursor:move;
1 cursor:text;
1 cursor:not‐allowed;
表单样式
1 input {
2 outline:none;
3 }
文本域样式
1 textarea {
2 resize:none;
3 }
对齐方式
1 vertical‐align:baseline | top | bottom | middle;
2 基线对齐 顶线 底线 中线
图片采用基线对齐后,底部有白色缝隙
文字省略
单行文本溢出显示省略号必须满足三个条件
1 white‐space:nowrap;
2 overflow:hidden;
3 text‐overflow:ellipis;
CSS3新增特性
选择器
属性选择器
选择具有value的input
1 input[value]{}
选择value="text"的input
1 input[value="text"]{}
选择icon开头的div
1 div[class^=icon]{}
选择data结尾的div
1 div[class$=data]{}
选择含有iii的div
1 div[class*="iii"]{}
结构伪类选择器
1 :first‐child{}
2 :last‐child{}
3 :nth‐child(n){}//n可为数字 1 , 2 , 3 关键字even 偶数,odd奇数
1 :first‐of‐type
2 :last‐of‐type
3 :nth‐of‐type(on)
伪元素选择器
1 div::before{
2 content="";
3 }
4 div::after{
5 content="";
6 }
C3盒子模型
1 box‐sizing:conten‐box;//传统盒子模型
2 box‐sizing:border‐box;//边框不占用大小,而是挤压内容
滤镜
1 filter:blur(5px);//进行布尔模糊
其他
1 width:calc(100%‐800px);
过渡
1 transition:all 1s;//所选属性 花费时间 运动曲线 何时开始
转换
1 transform:translate(100px,‐50px);//纯移动,保留源
2 transform:rotate(45deg);//顺时针旋转45°
3 transform:scale(2,2);//长和宽变为原来的 2 倍
4
5 transform:translate() rotate() scale();//简写
3D转换
1 transform‐style:flat | preserve;//开启3D空间(默认不开启)
2 prespective:500px;//开启透视 设置透视高度
3
4 transform:translate3d(x,y,x);//3d移动
动画
1 animation‐name:动画名称;
2 animation‐duration:3s;//动画时间
3 animation‐timing‐function:ease;//运动曲线
4 animation‐delay:5s;//五秒之后开始
5 animation‐iteration‐count:ifinite;//重复次数 无限
6 animation‐direction:alternate;//逆向
7 animation‐fill‐mode:forwards;//保持
8
9 animation:动画名称 动画时间 [速度曲线 何时开始 播放次数 是否反向 结束状态];
标准viewport视口设置
1 <meta name="viewport"
2 content="width=device‐width,
3 initial‐scale=1.0,
4 user‐scalable=no,
5 maximum‐scale=1.0,
6 minimum‐scale=1.0">
流式布局(百分)
宽度为百分比
flex布局
1 display:flex;
设置主轴方向
1 flex‐direction: row;
2 row‐reverse//右到左
3 column//上到下
4 column‐reverse//下到上
设置主轴的子元素排列方式
1 justify‐content:flex‐start;// 左对齐(默认)
2 flex‐end 右对齐
3 center 居中
4 space‐around 平均分配
5 space‐between 先两侧贴边然后平均分
设置子元素是否换行
1 flex‐wrap:nowrap;//不换行(默认)
2 wrap;//换行
设置侧轴上的子元素排列方式(单行)
1 align‐items:flex‐start;// 左对齐
2 flex‐end 右对齐
3 center 居中
4 stretch 拉伸(默认值)
设置侧轴上的子元素排列方式(多行)
1 align‐content:flex‐start;// 左对齐
2 flex‐end 右对齐
3 center 居中
4 space‐around 平均分配
5 space‐between 先两侧贴边然后平均分
6 stretch 拉伸(默认值)
flex子属性
1 flex:50%;
2 align‐self:flex‐start;子项在侧轴的排列方式(了解)
rem适配布局
em 父级字体大小
rem HTML字体大小
媒体查询
1 @media screen and (min‐width:500px){ //如果屏幕大于等于500px
2 html{
3 font‐size:14px;
4 }
5 }
less
1 @color1: skyblue;
2 @font14: 14px;
3 body{
4 background‐color:@color1;
5 font‐size:@font14;
6 a{
7 text‐decration:none;
8 &:hover{
9 background‐color:@color1;
10 font‐size:14px+16;
11 }
12 }
13 }
14 @import"common"//多个less合并在一起共同生成一份css文件
响应式布局
Bootstrap框架
CSS/CSS3语法新特性笔记的更多相关文章
- CSS3常用新特性
CSS3的新特性 新增CSS3特性有兼容性问题,ie9+才支持 移动端支持优于PC端 新增选择器和盒子模型以及其他特性 CSS新增选择器 属性选择器 属性选择器可以根据元素特定属性来选择元素,这样就可 ...
- HTML5和CSS3的新特性
html5的新特性 添加了用于媒介回放的 <video>,<audio> 元素 添加了语义标签譬如 header.footer.nav 等等元素 添加了用于绘画的 canvas ...
- css3的新特性选择器-------属性选择器
自己学css的时候比较乱,这次趁着复习把css3的新特性选择器和css2以前不怎么用的选择器做一个总结 <div id="parent"> <p>I'm a ...
- Java7语法新特性
Java7语法新特性: 1. switch中增加对String类型的支持. public String generate(String name, String gender) { String ti ...
- Atitit. c# 语法新特性 c#2.0 3.0 4.0 4.5 5.0 6.0 attilax总结
Atitit. c# 语法新特性 c#2.0 3.0 4.0 4.5 5.0 6.0 attilax总结 1.1. C# 1.0-纯粹的面向对象 1.2. C# 2.0-泛型编程新概念 1.3. ...
- CSS3的新特性
CSS3中增加的新特性: (1)选择器的种类 (2)字体 font (3)text-overflow (4)文本渲染 text-decoration (5)多列布局 column-count (6)R ...
- 任务十二:学习CSS 3的新特性
任务目的 学习了解 CSS 3 都有哪些新特性,并选取其中一些进行实战小练习 任务描述 实现 示例图(点击查看) 中的几个例子 实现单双行列不同颜色,且前三行特殊表示的表格 实现正常状态和focus状 ...
- C# 6.0语法新特性体验(二)
之前我在文章通过Roslyn体验C# 6.0的新语法中介绍了一些C# 6.0的语法特性,现在随着Visual Studio 14 CTP3的发布,又陆续可以体验一些新的特性了,这里简单的介绍一下之前没 ...
- ES6、7、8、9新语法新特性
前言 如果你擅长这种扩散式学习方式,不妨再进一步温习一下整个 ES6 引入的新特性,笔者强烈推荐阮一峰老师的 ECMAScript 6 入门 一书. ES2018 引入的特性还太新,单在对 ES6 特 ...
随机推荐
- 【简记】SpringBoot禁用Swagger
楔子 Swagger 是 Java Web 开发中常用的接口文档生成类库,在开发和前后端联调时使用它来模拟接口调用能提高开发效率.但是,在生产环境可能并不需要它,一个原因是启用它会延长程序启动时间(动 ...
- python3 爬取深圳主板公司名称,公司网址
需要阅读的文档: Requests:http://cn.python-requests.org/zh_CN/latest/user/quickstart.html BeautifulSoup:http ...
- Vue3源码分析之Diff算法
Diff 算法源码(结合源码写的简易版本) 备注:文章后面有详细解析,先简单浏览一遍整体代码,更容易阅读 // Vue3 中的 diff 算法 // 模拟节点 const { oldVirtualDo ...
- plsql 带参数的游标
-- 带参数的游标 -- cursor c(no emp.deptno%type) is select * from emp where deptno=no; 参数的起名 不要和表中的列名相同! -- ...
- JAVA类加载器二 通过类加载器读取资源文件
感谢原文作者:不将就! 原文链接:https://www.cnblogs.com/byron0918/p/5770684.html 一.getResourceAsStream方法 getResourc ...
- js注释和数据类型转换
单行注释 用来描述下面一个或多行代码的作用 // 这是一个变量var name = 'hm'; 多行注释 用来注释多条代码 /*var age = 18;var name = 'zs';console ...
- UIPickView的基本使用
UIPickView和TableView一样,想要展示数据也要设置数据源和代理设置数据源self.pickView.dataSource = self;设置代理self.pickView.delega ...
- Git Push 免输 用户名和密码
前言 在大家使用github的过程中,一定会碰到这样一种情况,就是每次要push 和pull时总是要输入github的账号和密码,这样不仅浪费了大量的时间且降低了工作效率.在此背景下,本文在网上找了两 ...
- request和session获取参数的区别
说简单点 request对象和session对象的最大区别是生命周期. request request范围较小一些,只是一个请求. request对象的生命周期是针对一个客户端(说确切点就是一个浏览器 ...
- Serializable接口中serialVersionUID字段的作用
序列化运行时使用一个称为 serialVersionUID 的版本号与每个可序列化类相关联,该序列号在反序列化过程中用于验证序列化对象的发送者和接收者是否为该对象加载了与序列化兼容的类. 如果接收者加 ...