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语法新特性笔记的更多相关文章

  1. CSS3常用新特性

    CSS3的新特性 新增CSS3特性有兼容性问题,ie9+才支持 移动端支持优于PC端 新增选择器和盒子模型以及其他特性 CSS新增选择器 属性选择器 属性选择器可以根据元素特定属性来选择元素,这样就可 ...

  2. HTML5和CSS3的新特性

    html5的新特性 添加了用于媒介回放的 <video>,<audio> 元素 添加了语义标签譬如 header.footer.nav 等等元素 添加了用于绘画的 canvas ...

  3. css3的新特性选择器-------属性选择器

    自己学css的时候比较乱,这次趁着复习把css3的新特性选择器和css2以前不怎么用的选择器做一个总结 <div id="parent"> <p>I'm a ...

  4. Java7语法新特性

    Java7语法新特性: 1. switch中增加对String类型的支持. public String generate(String name, String gender) { String ti ...

  5. 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. ...

  6. CSS3的新特性

    CSS3中增加的新特性: (1)选择器的种类 (2)字体 font (3)text-overflow (4)文本渲染 text-decoration (5)多列布局 column-count (6)R ...

  7. 任务十二:学习CSS 3的新特性

    任务目的 学习了解 CSS 3 都有哪些新特性,并选取其中一些进行实战小练习 任务描述 实现 示例图(点击查看) 中的几个例子 实现单双行列不同颜色,且前三行特殊表示的表格 实现正常状态和focus状 ...

  8. C# 6.0语法新特性体验(二)

    之前我在文章通过Roslyn体验C# 6.0的新语法中介绍了一些C# 6.0的语法特性,现在随着Visual Studio 14 CTP3的发布,又陆续可以体验一些新的特性了,这里简单的介绍一下之前没 ...

  9. ES6、7、8、9新语法新特性

    前言 如果你擅长这种扩散式学习方式,不妨再进一步温习一下整个 ES6 引入的新特性,笔者强烈推荐阮一峰老师的 ECMAScript 6 入门 一书. ES2018 引入的特性还太新,单在对 ES6 特 ...

随机推荐

  1. grafana ldap 权限无法保持

    一.Grafana介绍 Grafana是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知.它主要有以下六大特点: 1.展示方式:快速灵活的客户端图表,面板插 ...

  2. Kubeadm部署K8S(kubernetes)集群(测试、学习环境)-单主双从

    1. kubernetes介绍 1.1 kubernetes简介 kubernetes的本质是一组服务器集群,它可以在集群的每个节点上运行特定的程序,来对节点中的容器进行管理.目的是实现资源管理的自动 ...

  3. WebAssembly编译

    环境:centos 7.9 1.准备环境 sudo yum install docker sudo systemctl start docker.service sudo docker pull tr ...

  4. 使用XmlWriter写入XML

    麻了..整理完了发现XmlWriter不能添加元素,只能重写,还是得用Xdocument..好像DOM能实现添加元素 点击查看代码 **MemoryStream msXml = new MemoryS ...

  5. 掌握这些常用Linux命令,一起提升工作效率

    开始上班了,新一年的奋斗的之路启程了,要继续[奔赴山海,奔赴热爱]. 汪国真在<热爱生命>这首诗中写到:既然选择了远方,便只顾风雨兼程.技术上还是持续精进和学习,远方虽远,要迈开脚步,一步 ...

  6. Callable接口及Futrue接口详解

    Callable接口 有两种创建线程的方法-一种是通过创建Thread类,另一种是通过使用Runnable创建线程.但是,Runnable缺少的一项功能是,当线程终止时(即run()完成时),我们无法 ...

  7. 简单的MAC的终端命令

    今天小研究了一下MAC的终端命令,主要为了方便调试程序用,XCODE用不来啊... 在这里记下..防止丢失 pwd 当前工作目录 cd(不加参数) 进root cd(folder) 进入文件夹 cd ...

  8. MySQL基本命令语法之select

    目录 MySQL基本命令语法之select 查询去重以及常数 空值与着重号 着重号 空值 运算符 算术运算符 比较运算符 符号型 非符号型 逻辑运算符 优先级 排序分页 排序 分页 拓展 多表查询 等 ...

  9. Java判断是否是回文字符串

    public static boolean isPalindrome(String str) { int start = 0, end = str.length() - 1; while (start ...

  10. HMS Core助力宝宝巴士为全球开发者展现高品质儿童数字内容

    本文分享于HMS Core开发者论坛<宝宝巴士携HMS Core为全球家庭用户提供优质儿童数字内容>采访稿整理 宝宝巴士是国内有着十多年出海经验的开发者,其旗下有超过200多款儿童益智互动 ...