天总结的是CSS3的学习内容
CSS3是CSS技术的升级版本,CSS即层叠样式表(Cascading StyleSheet)。CSS3语言是朝着模块化发展的,把它分解成小的模块,并且加入 更多新的模块进来:
盒子模型
文字特效
边框圆角
动画
多列布局
用户界面
旋转
渐变
...CSS选择器:使用CSS对html页面中的元素实现一对一,一对多或者多对一的控制:
选择器
{
样式
}1.属性选择器
在CSS3中追加了三个选择器:[att*=val];[att^=val];[att$=val]–>att表示为属性,val表示为属性的属性值。
[att*=val]:如果元素用att表示的属性的值中包含val指定的字符,那么该元素使用这个样式。
[att$=val]:如果元素用att表示的属性的属性值的结尾字符用val指定的字符,那么该元素使用这个样式。
[att^=val]:如果元素用att表示的属性的属性值的开头字符为用val指定的字符,那么该元素使用这个样式。
注意: /如果纯用数字的时候该样式不会显示成功,需要用\连接与数字最近的符号 注意!只有’-‘的字符需要加’\’/
<head>
<meta charset="UTF-8">
<title>css3中的属性选择器</title>
<style>
/*1.[att*=val] 此时只有id=section1A的div会拥有该样式*/
[id*= section1]{
background-color: blueviolet;
}
/*2.[att^=val] 此时只有id=footer的div会拥有该样式*/
[id^= f]{
background-color: blue;
}
/*3.[att$=val] 此时只有id=sectionB的div会拥有该样式*/
[id$= B]{
background-color: chartreuse;
}
/*注意!*/
[id$= \-1]{
background-color: crimson;
}
</style>
</head>
<body>
<h1>CSS3中的属性选择器</h1>
<div id="section1A">section1A</div>
<div id="sectionB">sectionB</div>
<div id="section2-1">section2-1</div>
<div id="footer">footer</div>
</body>2.结构性伪类选择器
(1)类选择器
使用类选择器把相同的元素定义成不同的样式,伪类选择器是已经定义好的不可以随便起名。
p.right{
color:red;
}
p.left{
colot:blue;
}(2)伪类选择器—-最常见的伪类选择器:a(使用顺序为:未,已,悬,停)
a:link{
color: #ff6600;
}
a:visited{
color: blueviolet;
}
a:hover{
color: aqua;
}
/*鼠标点击时*/
a:active{
color: darkblue;
}(3)伪元素选择器
针对于CSS中已经定义好的伪元素使用的选择器(first-line;first-letter;before;after)。
选择器:伪元素{
属性:值;
}
选择器.类名:伪元素{
属性:值;
}我自己是一名从事了多年开发的web前端老程序员,目前辞职在做自己的web前端私人定制课程,今年年初我花了一个月整理了一份最适合2019年学习的web前端学习干货,各种框架都有整理,送给每一位前端小伙伴,想要获取的可以关注我的头条号并在后台私信我:前端,即可免费获取
first-line伪元素选择器:向某个元素中的第一行文字使用样式。
first-letter伪类选择器:向某个元素中的文字的首字母或者第一个文字使用样式。
before:在某个元素之前插入一些内容。
after:在某个元素之后插入一些内容。
可以使用before和after伪元素在页面中插入文字,图像,项目编号等。
插入文字:E:before/after
排除一些不需要插入内容的元素:E:none:before/after
插入图像
插入项目编号
a.在多个标题前加上编号:counter属性对项目追加编号
元素:before{
content:counter(计数器);
}
元素{
counter-increment:content属性值中所指定的计数器名称;
} b.对编号中添加文字
c.指定编号的样式
d.指定编号的种类:list-style-type
e.编号嵌套,重置编号
要对哪一个元素进行重置,那么就在该元素的父元素上进行设置reset。
f.中编号中嵌入大编号 h2:before{
content:counter(大编号计数器)'-'conter(中编号计数器); g.在字符串两边嵌套文字符号:open-quoter&close-quoter<head>
<meta charset="UTF-8">
<title>伪元素选择器</title>
<style>
p:first-line{
color: blueviolet;
}
p:first-letter{
color: aqua;
}
li:before{
content: "~~~";
color: #000;
}
li:after{
content: "~~~";
color: darkred;
}
</style>
</head>
<body>
<h1>CSS中主要有四个伪类选择器</h1>
<p>
CSS中主要有四个伪类选择器<br />
first-line伪元素选择器:向某个元素中的第一行文字使用样式
</p>
<p>
first-letter伪类选择器:向某个元素中的文字的首字母或者第一个文字使用样式
</p>
<h4>befor&after</h4>
<ul>
<li><a href="first.html">balabala</a></li>
</ul>
</body>(4)结构性伪类选择器
<head>
<style>
/*empty选择器*/
:empty{
background-color: darkviolet;
}
</style>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td></td>
</tr>
</table>
</body><head>
<style>
/*target选择器*/
:target{
background-color: blanchedalmond;
color: brown;
}
</style>
</head>
<body>
<h2>target选择器</h2>
<a href="#A">A</a>
<a href="#B">B</a>
<div id="A">
<h2>A标题</h2>
<p>内容</p>
</div>
<div id="B">
<h2>B标题</h2>
<p>内容</p>
</div>
</body>first-child:单独指定第一个子元素的样式。
last-child:单独指定最后一个子元素的样式。
nth-child:选择器匹配正数下来的第N个子元素,nth-child(odd)为第奇数个子元素,nth-child(even)为第偶数个子元素。
nth-last-child(n):匹配倒数数下来第n个子元素。
nth-of-type:正数,当指定元素为标题加内容的时候,如果使用上面的方法会导致真正的指定元素不被成功指定,因此需要使用nth-first-type方法进行指定。
nth-last-type:倒数,同nth-first-type。
循环使用样式:nth-child(An+B)–A 表示每次循环中共包括几种样式,B表示指定的样式在循环中所处的位置。
only-child:只对一个元素起作用。
<head>
<meta charset="UTF-8">
<title>结构性伪类选择器</title>
<style>
/* 选择器first-child;last-child;nth-child;nth-last-child*/
li:first-child{
background-color: darkviolet;
}
li:last-child{
background-color: chartreuse;
}
li:nth-child(3){
background-color: cadetblue;
}
li:nth-child(odd){
background-color: aquamarine;
}
li:nth-child(even){
background-color: cornflowerblue;
}
li:nth-last-child(3){
background-color: darkgrey;
}
/*循环*/
li:nth-child(4n+1){
background-color: aquamarine;
}
li:nth-child(4n+2){
background-color: indianred;
}
/*唯一的*/
li:only-child{
background-color: hotpink;
}
/*存在的问题*/
h2:nth-child(2){
background-color: darkgoldenrod;
}
h2:nth-child(odd){
background-color: darkgoldenrod;
}
h2:nth-child(even){
background-color: darkgoldenrod;
}
h2:nth-of-type(odd){
background-color: chartreuse;
}
h2:nth-of-type(even){
background-color: aquamarine;
}
</style>
</head>
<body>
<h1>选择器first-child;last-child;nth-child;nth-last-child</h1>
<ul>
<li>No.1</li><li>No.2</li><li>No.3</li><li>No.4</li>
<li>No.5</li><li>No.6</li><li>No.7</li><li>No.8</li>
<li>No.9</li><li>No.10</li>
<li>No.11</li><li>No.12</li>
</ul>
<h1>唯一的</h1>
<ul>
<li>唯一,多加一个就没有啦</li>
</ul>
<div id="A">
<h2>A标题</h2><p>内容</p>
<h2>B标题</h2><p>内容</p>
</div>
</body>3.UI元素状态伪类选择器
指定的样式只有在元素处于某种状态下才起作用,在默认状态下不起作用!
选择器:伪元素{
属性:值;
}
选择器.类名:伪元素{
属性:值;
}first-line伪元素选择器:向某个元素中的第一行文字使用样式。
first-letter伪类选择器:向某个元素中的文字的首字母或者第一个文字使用样式。
before:在某个元素之前插入一些内容。
after:在某个元素之后插入一些内容。
可以使用before和after伪元素在页面中插入文字,图像,项目编号等。
插入文字:E:before/after
排除一些不需要插入内容的元素:E:none:before/after
插入图像
插入项目编号
a.在多个标题前加上编号:counter属性对项目追加编号
元素:before{
content:counter(计数器);
}
元素{
counter-increment:content属性值中所指定的计数器名称;
} b.对编号中添加文字
c.指定编号的样式
d.指定编号的种类:list-style-type
e.编号嵌套,重置编号
要对哪一个元素进行重置,那么就在该元素的父元素上进行设置reset。
f.中编号中嵌入大编号 h2:before{
content:counter(大编号计数器)'-'conter(中编号计数器); g.在字符串两边嵌套文字符号:open-quoter&close-quoter <head>
<meta charset="UTF-8">
<title>伪元素选择器</title>
<style>
p:first-line{
color: blueviolet;
}
p:first-letter{
color: aqua;
}
li:before{
content: "~~~";
color: #000;
}
li:after{
content: "~~~";
color: darkred;
}
</style>
</head>
<body>
<h1>CSS中主要有四个伪类选择器</h1>
<p>
CSS中主要有四个伪类选择器<br />
first-line伪元素选择器:向某个元素中的第一行文字使用样式
</p>
<p>
first-letter伪类选择器:向某个元素中的文字的首字母或者第一个文字使用样式
</p>
<h4>befor&after</h4>
<ul>
<li><a href="first.html">balabala</a></li>
</ul>
</body>(4)结构性伪类选择器
<head>
<style>
/*empty选择器*/
:empty{
background-color: darkviolet;
}
</style>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td></td>
</tr>
</table>
</body><head>
<style>
/*target选择器*/
:target{
background-color: blanchedalmond;
color: brown;
}
</style>
</head>
<body>
<h2>target选择器</h2>
<a href="#A">A</a>
<a href="#B">B</a>
<div id="A">
<h2>A标题</h2>
<p>内容</p>
</div>
<div id="B">
<h2>B标题</h2>
<p>内容</p>
</div>
</body>first-child:单独指定第一个子元素的样式。
last-child:单独指定最后一个子元素的样式。
nth-child:选择器匹配正数下来的第N个子元素,nth-child(odd)为第奇数个子元素,nth-child(even)为第偶数个子元素。
nth-last-child(n):匹配倒数数下来第n个子元素。
nth-of-type:正数,当指定元素为标题加内容的时候,如果使用上面的方法会导致真正的指定元素不被成功指定,因此需要使用nth-first-type方法进行指定。
nth-last-type:倒数,同nth-first-type。
循环使用样式:nth-child(An+B)–A 表示每次循环中共包括几种样式,B表示指定的样式在循环中所处的位置。
only-child:只对一个元素起作用。
<head>
<meta charset="UTF-8">
<title>结构性伪类选择器</title>
<style>
/* 选择器first-child;last-child;nth-child;nth-last-child*/
li:first-child{
background-color: darkviolet;
}
li:last-child{
background-color: chartreuse;
}
li:nth-child(3){
background-color: cadetblue;
}
li:nth-child(odd){
background-color: aquamarine;
}
li:nth-child(even){
background-color: cornflowerblue;
}
li:nth-last-child(3){
background-color: darkgrey;
}
/*循环*/
li:nth-child(4n+1){
background-color: aquamarine;
}
li:nth-child(4n+2){
background-color: indianred;
}
/*唯一的*/
li:only-child{
background-color: hotpink;
}
/*存在的问题*/
h2:nth-child(2){
background-color: darkgoldenrod;
}
h2:nth-child(odd){
background-color: darkgoldenrod;
}
h2:nth-child(even){
background-color: darkgoldenrod;
}
h2:nth-of-type(odd){
background-color: chartreuse;
}
h2:nth-of-type(even){
background-color: aquamarine;
}
</style>
</head>
<body>
<h1>选择器first-child;last-child;nth-child;nth-last-child</h1>
<ul>
<li>No.1</li><li>No.2</li><li>No.3</li><li>No.4</li>
<li>No.5</li><li>No.6</li><li>No.7</li><li>No.8</li>
<li>No.9</li><li>No.10</li>
<li>No.11</li><li>No.12</li>
</ul>
<h1>唯一的</h1>
<ul>
<li>唯一,多加一个就没有啦</li>
</ul>
<div id="A">
<h2>A标题</h2><p>内容</p>
<h2>B标题</h2><p>内容</p>
</div>
</body>3.UI元素状态伪类选择器
指定的样式只有在元素处于某种状态下才起作用,在默认状态下不起作用!
4.兄弟元素选择器
用来指定位于同一父元素之中的某个元素之后的所有其他某个种类的兄弟元素所使用的样式。一定要是之后的兄弟元素!
<子元素>~<子元素之后的同级兄弟元素>
{
样式
}1.text-shadowp{
text-shadow:length(阴影离开文字的横方向距离) length(阴影离开文字的纵方向距离) length(阴影模糊半径) color(阴影颜色)
}位移距离:前两个参数代表的阴影离开文字的横(纵)方向距离,不可省略。
第三个参数代表模糊半径,代表阴影向外模糊时候的范围,数值越大越模糊。
当没有指定颜色值时,会使用默认文字的颜色。
指定多个阴影,并且可以针对每个阴影用逗号分隔。
2.word-break:浏览器文本自动换行。
3.word-wrap: 长单词与URL地址自动换行。
4.服务器端字体和@font-face属性
定义斜体或粗体:在定义字体的时候,可以把字体定义成斜体或者粗体,在使用服务器服务器端字体的时候,需要根据斜体还是粗体使用不同的汉字。
显示客户端字体:首先将font-family设置为本地的字体名,然后将src属性设置为local(‘字体’)。
font-variant:设置文本是否大小写。
font-weight:设置文本的粗细。
font-stretch:设置文本是否横向的拉伸变形。
2.3.盒模型
1.各种盒模型
inline-block类型
使用inline-block类型来执行分列显示
<head>
<style>
div.div1{
background-color: #ff6600;
width: 300px;
height: 150px;
float: left;
}
div.div2{
background-color: #21fffc;
width: 200px;
height: 100px;
float: left;
}
div.div3{
background-color: #ef23ff;
width: 500px;
height: 100px;
clear: both;
}
/*inline-block*/
div.div4{
background-color: #ff6600;
display: inline-block;
width: 300px;
}
div.div5{
background-color: #21fffc;
vertical-align: top;
display: inline-block;
width: 200px;
}
div.div6{
background-color: #ef23ff;
width: 500px;
height: 100px;
}
</style>
</head>
<body>
<h1>使用inline-block类型来执行分列显示-1.传统方式</h1>
<div class="div1">div1</div>
<div class="div2">div2</div>
<div class="div3">div3</div>
<hr color="darkred">
<h1>使用inline-block类型来执行分列显示-1.inline-block方式</h1>
<div class="div4">
div1div1div1div1div1div1div1
div1div1div1div1div1div1div1div1
div1div1div1div1div1div1div1div1
</div><div class="div5">
div2div2div2div2div2div2div2
div2div2div2div2div2div2div2div2
</div>
<div class="div6">
div3
</div>
</body>使用inline-block类型来显示水平菜单<head>
<style>
ul.ul1 li{
float: left;
list-style: none;
padding:5px 20px;
text-align: center;
border-right: 1px solid darkviolet;
width: 200px;
color: wheat;
background-color: mediumvioletred;
}
ul.ul2 li{
list-style: none;
display: inline-block;
padding:5px 20px;
text-align: center;
border-right: 1px solid darkviolet;
width: 200px;
color: wheat;
background-color: mediumvioletred;
}
</style>
</head>
<body>
<h1>使用inline-block类型来显示水平菜单-inline-block</h1>
<ul class="ul2">
<li>A</li><li>B</li><li>C</li><li>D</li>
</ul>
</body>
使用inline-block类型来显示水平菜单<head>
<style>
ul.ul1 li{
float: left;
list-style: none;
padding:5px 20px;
text-align: center;
border-right: 1px solid darkviolet;
width: 200px;
color: wheat;
background-color: mediumvioletred;
}
ul.ul2 li{
list-style: none;
display: inline-block;
padding:5px 20px;
text-align: center;
border-right: 1px solid darkviolet;
width: 200px;
color: wheat;
background-color: mediumvioletred;
}
</style>
</head>
<body>
<h1>使用inline-block类型来显示水平菜单-inline-block</h1>
<ul class="ul2">
<li>A</li><li>B</li><li>C</li><li>D</li>
</ul>
</body>
<head>
<style>
table{
display: inline-table;
vertical-align: bottom;
border: 2px solid blueviolet;
width: 400px;
height: 200px;
color: darkviolet;
}
td{
border: 2px solid violet;
}
</style>
</head>
<body>
<h1>使用inline-table类型-一个表格前后都有文字将其环绕</h1>
巴拉巴拉
<table cellspacing="0" cellpadding="0">
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
巴拉巴拉
</body>list-item类型
可以将多个元素作为列表显示,同时在元素的开头加上列表的标记。
run-in类型和compact类型
none类型
当元素被指定none后,该元素不会显示
2.显示不下的内容
overflow属性:指定对盒子中容纳不下的内容的显示办法
overflow-x属性与overflow-y属性
textoverflow:在盒子的末尾显示代表省略符号的‘…’,但是该属性只在内容在水平位置上超出时显示。
3.盒子阴影
box-shadow:让盒在显示的时候产生阴影的效果
对盒内子元素设置阴影
对一个文字或第一行设置阴影:通过first-line或者first-letter
对表格和对单元格使用阴影
4.box-sizing宽高计算
指定针对元素的宽度和高度的计算方法
(content)border-box:属性值表示元素的宽高度(不)包括内补白区域及边框的宽度高度<head>
<style>
div.a,div.b{
width: 300px;
padding: 30px;
margin: 20px auto;
border: 30px solid darkviolet;
background-color: violet;
}
div.a{
box-sizing: border-box;
}
div.b{
box-sizing: content-box;
}
</style>
</head>
<body>
<h2>box-sizing:content&border-box</h2>
<div class="ab">
<div class="a">
box-sizing:border-box代表宽度和高度包含内补白宽度高度,即虽然有padding和border,最终仍然为300px
</div>
<div class="b">
box-sizing:content-box:代表不包含宽高度内补白区域,即最后为300px+30px+30px
</div>
</div>
</body>2.4.边框和背景样式
1.新增的背景属性
background-clip:指定背景的显示范围
border-box:从边框开始
padding-box:从内边框开始
content-box:从内容开始
background-orgin:指定绘制背景图像的起点
可以指定绘制时的起始位置,默认为padding,可以为border或者content左上角开始绘制。
background-size:指定背景中图像的尺寸
auto
length
percentage:以父元素的百分比设置背景图像的宽高度。
cover:全覆盖。
contain :与cover相反,主要将背景图片缩小,来适合布满整个容器。
2.显示多个背景属性: 第一个图像在最上面
3.圆角边框:border-radius
指定两个半径:左上右下+左下右上
当不显示边框的时候,浏览器会把四个角绘制成圆角
修改边框种类。
绘制四个不同半径的边框
4.图像边框:border-image
可以让元素的长度或宽度处于随时变化时,变化状态的边框统一使用一个图像文件来进行绘制。
2.5.CSS3变形功能
1.利用transform实现文字或图像的旋转,缩放,倾斜移动这四种类型的变形处理。
旋转:totate(角度)
缩放:scale(值):0.5即为缩放到50%
倾斜:skew(值),值为角度
移动:translate(值)
对一个元素使用多个方法
transform:方法1 方法2 方法 3 方法4
改变元素基点
transform-origin:
2.6.CSS3的动功能
1.transition功能:支持从一个属性值平滑到另外一个属性值
允许CSS属性值在一定的时间内平滑的过度,这种效果可以在单击,获得焦点,被点击或对元素任何改变中触发,并圆滑的以动画效果改变CSS属性值。
(1)执行变换的属性:transition-property:过渡即将开始
none:没有属性会获得过渡效果
all:所以属性会获得过渡效果
property:定义应用过渡效果的CSS属性名称列表,以逗号分隔
(2)变换延续时间:transition-duration:规定完成过渡需要花费的时间,默认值零没有效果。
(3)在延续时间段,变换速率的变化:transition-timing-function。
(4)变换延迟时间:transition-delay:指定一个动画开始执行的时间,也就是当改变元素属性值后多长时间开始执行过渡效果。
<head>
<meta charset="UTF-8">
<title>CSS3中的动画效果</title>
<style>
div.transition1{
width: 200px;
height: 200px;
background-color: blueviolet;
-webkit-transition:all 1s linear 1s;
}
</style>
</head>
<body>
<h2>transition</h2>
<div class="transition1"></div>
</body>2.Animations功能:支持通过关键帧的指定来在页面上产生更复杂的动画现象。
<head>
<style>
div.animation{
width: 20px;
height: 20px;
background-color: #ef23ff;
}
/*关键帧的封装*/
@-webkit-keyframes myan{
0%{
background-color: violet;
width: 50px;
}
10%{
background-color: palevioletred;
width: 100px;
}
30%{
background-color: mediumvioletred;
width: 200px;
}
50%{
background-color: blueviolet;
width: 40px;
}
70%{
background-color: darkviolet;
width: 400px;
}
90%{
background-color: #7300a4;
width: 600px;
}
100%{
background-color: #4a0068;
width: 800px;
}
}
</style>
</head>
<body>
<h2>animation</h2>
<div class="animation"></div>
</body>2.7.CSS3的分页
1.点击及鼠标悬停分页样式
2.鼠标悬停过渡效果:transition: background-color .9s;
3.圆角样式:border-radius
4.边框:border:2px solid darkviolet;
2.8.布局相关样式
1.多栏布局
column-count属性:将一个元素中的内容分成多栏进行显示,要将元素的宽度设置成多个栏目的总宽度
column-width属性:指定栏目的宽度来生成分栏
column-gap属性:指定栏目之间的距离
column-rule:栏目之间添加分隔线
2.盒布局: 多栏布局的栏目宽度必须相等,指定栏目的宽度的时候也只能统一指定,但是栏目的宽度不可能全部都一样,所以多栏布局比较适合在文字内容页面显示,比如新闻。并不适合整个网页编排时使用。而盒布局就相对比较随意一些,可以定义成不同的页面。
3.弹性盒子布局
(1)box-flex:使得盒子布局变成弹性布局:可以自适应窗口
(2)box-ordinal-group:改变元素的显示顺序
(3)box-orient:改变元素排列方向
horizontal:在水平行中从左向右排列子元素
vertical:从上向下垂直排列子元素
<style>
div.all{
display: -webkit-box;
/*-webkit-box-orient: vertical;窗口垂直现实与水平显示*/
}
.left{
width: 300px;
background-color: #ef23ff;
-webkit-box-ordinal-group:3;
}
.right{
width: 300px;
background-color: #ef23ff;
-webkit-box-ordinal-group: 2;
}
.center{
-webkit-box-flex:1;
background-color: #962fff;
-webkit-box-ordinal-group: 1;
}
</style>
(4)元素的高度宽度自适应:就是元素的高度和宽度可以根据排列的方向改变而改变。
(5)使用弹性布局来消除空白:方法就是给子div中加入一个box-flex属性。
<style>
.center1{
display: -webkit-box;/*盒模型显示*/
border: 5px solid darkviolet;
-webkit-box-orient: horizontal;/*水平显示*/
width: 600px;
height: 400px;
}
.d1{
background-color: #ff99e1;
-webkit-box-flex: 2;
}
.d2{
background-color: #962fff;
-webkit-box-flex: 3;
}
.d3{
background-color: #ef23ff;
-webkit-box-flex: 4;
}
.d1,.d2,.d3{
-webkit-box-sizing: border-box;
}
</style>(6)对多个元素使用box-flex属性,让浏览器或者容器中的元素的总宽度或者总高度都等于浏览器或者容器高度。
(7)box-pack属性和box-align属性:指定水平方向与垂直方向的对齐方式(文字,图像,以及子元素的水平方向或是垂直方向上的对齐方式)
2.9.不同浏览器加载不同的CSS样式
Media Queries模块是CSS3中的一个和各种媒体相关的重要模块
原文链接:https://blog.csdn.net/qq_27348951/article/details/53378364
TML 已经发展了多年,现在 W3C 已经发布了 HTML 5.1 的提案推荐标准,一些陈旧废弃的标签已经在后继的标准中逐渐消失。这里为大家列出那些已经被废弃 HTML 标签,看看你是不是还在使用它们。 |
HTML 已经发展了多年,现在 W3C 已经发布了 HTML 5.1 的提案推荐标准,一些陈旧废弃的标签已经在后继的标准中逐渐消失。这里为大家列出那些已经被废弃 HTML 标签,看看你是不是还在使用它们。
<acronym>
首字母缩写,例如 WWW
类似的有<abbr>标签,表示单词缩写,例如:<abbr>inc.</abbr>。语法如下:
<acronym title="World Wide Web">WWW</acronym>
<abbr title="incorporated">inc.</abbr>推荐用<abbr>,不要用<acronym>(忽略上面提到的语义上的差异)。
<applet>
Java 小应用程序,主要提供绘图功能(在页面上通过代码绘制一些东西),例如:
<applet code="ShowImage.class" width=600 height=400 archive="Imagetest.jar"></applet>目前几乎没什么用了,因为运行需要 JRE,而目前主流浏览器并不默认安装 JRE。
推荐使用<canvas>绘图,或者用<object>+<embed>嵌入 flash代替<applet>。
注意:使用<object> +<embed> 是为了更好的兼容性,如果场景允许,推荐使用<object>。
<basefont>
<basefont>
标签定义基准字体。该标签可以为文档中的所有文本定义默认字体颜色、字体大小和字体系列,例如:
<basefont color="red" size="5" face="Arial" /><basefont>
标签只有 IE 支持。
推荐直接给<body> 元素定义默认字体,所有子元素都会继承这些属性值。
<bgsound>
用来添加背景音乐,例如:
<bgsound src="your.mid" autostart="true" loop="infinite">推荐使用<audio> 或者<object>+<embed>来代替,例如:
<embed src="your.mid" autostart="true" loop="true" hidden="true"><big>
用来放大字体,放大一号(嵌套多层可以放大更多),不支持的浏览器显示粗体,例如:
<big>大1号</big><big><big>大2号</big></big>至于“号”是怎么定义的就别管了,不推荐使用,建议根据语义采用<em>、<strong>或者自定义样式类代替。
<blink>
可以实现闪烁效果,例如:
<blink>Why would somebody use this?</blink>支持性很差,不推荐使用,同样不推荐使用(各大浏览器支持<blink>,但没有任何效果):
<p>This should be avoided as well.</p>建议采用<animation>代替
<center>
使内容居中,例如:
<center>文本及子元素会居中</center>效果类似于如下 CSS:
text-align: center;不建议使用,确实没有任何理由去用。
<dir>
目录列表,例如:
<dir>
<li>html</li>
<li>xhtml</li>
<li>css</li>
</dir>
效果和<ul>基本相同,浏览器默认样式下列表项的左边距有细微差异。
不推荐使用,建议根据语义采用<ul>、<ol>或者<dl>。
<font>
用来定义字体、字号和颜色,例如:
<font face="verdana" color="green" size="3">This is some text!</font>属性值和<basefont>一样。
不推荐使用,建议用 CSS 代替,没理由用这个标签。
<frame>
配合<frameset>分栏,例如:
<!DOCTYPE html>
<html>
<frameset cols="25%,*,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
</frameset>
</html>
注意:用<frameset>替换掉<body>。
复杂的后台页面会用到<frameset>+<frame><hgroup>
给一系列标题分组,例如:
<hgroup>
<h1>The reality dysfunction</h1>
<h2>Space is not the only void</h2>
</hgroup>
虽然提供了一点语义,但因为已经过时,所以不推荐使用。
建议采用><header>代替,例如:
<header>
<h1>The reality dysfunction</h1>
<p class="subheading">Space is not the only void</p>
</header>
<isindex>
单行文本控件,初始显示prompt属性值,例如:
<isindex prompt="string" />目前支持性很差,不推荐使用,建议用<input>元素代替。
W3C 建议千万不要用:
No, really, don’t use it. This element is deprecated. It is not implemented anymore.
具体用法可以参考 http://reference.sitepoint.com/html/isindex。
<listing>
不用管它是什么,微软都不建议使用了:
This element is obsolete and should no longer be used. Use HTMLPreElement, code or CSS instead. Renders text in a fixed-width font.
<marquee>
滚动字幕,效果很强大,例如:
<marquee bgcolor="#ccffff" vspace="10" direction="up" height="104" width="22.35%" loop="3" scrollamount="1" scrolldelay="10" hspace="20">
<p align="center"><font color="#000000">此处输入滚动内容</font></p></marquee>
<marquee>这里是输入文字的地方,还可以放图片代码、Flash动画代码和gif动态小图代码。</marquee>多用来实现公告,虽然已经过时了,但效果确实很强大,而且支持性良好。
<multicol>
用来实现多列布局,不建议使用,任何主流浏览器都不曾支持过。
MDN 称其从未被任何主流浏览器支持过:
The HTML element was an experimental element designed to allow multi-column layouts. It never got any significant traction and is not implemented in any major browsers.
<nextid>
作用未知,支持性未知,不建议使用。
<nobr>
禁止换行,例如:
<p>Our telephone number is <nobr>0800 123 123 123</nobr>.</p>
不推荐使用,建议用 CSS 代替:
white-space: nowrap;<noembed>
在浏览器不支持<embed>时,显示内容,类似于<noscript>,例如:
<noembed>
<img src="/images/inflate.jpg" alt="Inflate the tyre by holding the
pump at 90 degree angle to the valve">
<p>You can inflate the tyre by holding the pump at 90 degree angle
to the valve, as shown in the image above.</p>
</noembed>
不推荐使用,如果需要考虑兼容性的话,建议采用<object>+<embed>+<noembed>(embed / noembed 作为 object 的回退)。
<noframes>
在浏览器不支持<frameset>+<frame>时,显示内容,类似于<noscript>,例如:
<html>
<frameset cols="25%,50%,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
<noframes>Sorry, your browser does not handle frames!</noframes>
</frameset>
</html>
<noframe>标签中可以包含任何能够出现在<body>中的标签。
如果需要考虑兼容性的话,可以作为<frame>的回退,建议采用 float/flex + Ajax 实现,根据具体场景来定。
<plaintext>
忽略内容中的html标签,作用类似于><pre>,例如:
<p>The markup for this is:</p>
<plaintext>
<h1>Main heading goes here</h1>
<p>First paragraph goes here</p>
<h2>Sub-heading goes here</h2>
</plaintext>.
</body>
</html>
不推荐使用,建议根据语义用<pre>或者<code>代替。
<spacer>
插入空白white spaces,例如:
<span>Just a text node</span>
<spacer type="horizontal" size="10"></spacer>
<span>Just another text node</span>
<spacer type="block" width="10" height="10"></spacer>
主流浏览器都不支持,不推荐使用。
<strike>
删除线,效果类似于<del>和<s>,例如:
<p>Version 2.0 is <strike>not yet available!</strike> now available!</p>
不推荐使用,建议用><del>代替。
<tt>
键盘输入(teletype),例如:
<p><tt>Teletype text</tt></p>
不推荐使用,建议根据语义用<kbd>(键盘按键)、<var>(变量)、<code>(代码)、<samp>(样例输出)或者CSS代替。
<xmp>
80 列的样例输出,样式效果类似于<pre>,语义类似于<samp>,例如:
<xmp>
Stock ID Description Price Quantity in Stock
-------- ----------- ----- -----------------
116 Inflatable Armchair 21.50 13
119 Walkie Talkie 40.20 44
</xmp>
目前浏览器支持该标签,但不限制 80 列。
不推荐使用,建议采用<samp>代替。
https://www.linuxprobe.com/html-w3c-mdn.html
觉导向的斟酌
容易阅读=容易看+容易理解
①内容和字体的关系
Ⅰ.字号
这里主要讲偏书籍、杂志、手册类的排版规则。
标题:大标题>小标题>副标题>引言>正文
正文:一般至少为9pt,如果面向的是儿童、老人这类人群,则需酌情放大字体。
补充说明:如批注,图片说明、原作者等,一般在6.5pt左右。
Ⅱ.边界&对比
边界即画面上下左右的边距留白,这里我觉得用HTML排版里,比较典型的盒子模型为例:
边界的比例,尤其是在书籍印刷上,给人心理的愉悦度影响程度很大。
比如窄边距,往往有一种压迫感,两眼一黑…(快…快拿莎普爱思救我…)
对比分几种:
字号大小对比
重量粗细对比
字体形状对比
文字色彩对比
当然啦~对比主要是将文字动静分化开~比较有主次、冲击力。
②易于阅读的排版
Ⅰ.行长/行距/分栏
当文章较长时,行长、行距、分栏的设定往往会决定读者的阅读节奏。
如果阅读节奏和主题内容较为吻合,往往能得到较好的阅读体验,甚至能增强代入感。
行长:即每行长度,太长会给人疲累感(太长不看-v-),太短会给人频繁换行的阅读上的不快。
行距:每行间的留白,通常8pt的正文字号,适合行距在1.3mm~2.72mm之间。
分栏:栏数越多往往意味着行长缩减,故应结合行长调整。
Ⅱ.文字间距
文字间距是个神奇的东西,往往它决定着文字在阅读时的“韵律感”。
西方字体,如W和I,其字体宽度本来就不同(来感受一下:WIWIWIWI IIIIIIWWW)
但是东方字体,,每个字占据空间相同,几乎都是一个个正方形方块。
字距狭窄:突出密度感、紧凑感。
字句宽松:给人舒适怡然感、结合细体文字往往有一种设计感。
最后,关于视觉的引导性。
举几个极端的例子大家就懂,了比如:
——或者:
更多精彩内容请关注微信公众号:prouduct
投稿邮箱:prouduct@sina.com
*请认真填写需求信息,我们会在24小时内与您取得联系。