CSS 是什么?
CSS是Cascading Style Sheets的简称,中文称为层叠样式表。
属性和属性值用冒号隔开,以分号结尾。
CSS 四种引入方式:
1.行内式
行内式是在标签的style属性中设定CSS样式。
<div style="..."></div>
2.嵌入式
嵌入式是将CSS样式集中写在网页的<head>标签的<style></style>标签对中。
<head>
...
<style type="text/css">
...此处写CSS样式
</style>
</head>
3.导入式
将一个独立的.css文件引入HTML文件中,导入式使用@import 引入外部CSS文件,<style>标记也是写在<head>标记中。
导入式会在整个网页装载完后再装载CSS文件。
<head>
...
<style type="text/css">
@import "My.css"; 此处注意.css文件的路径
</style>
</head>
4.链接式
将一个独立的.css文件引入到HTML文件中,使用<link>标记写在<head>标记中。
链接式会以网页文件主体装载前装载CSS文件。
<head>
...
<link href="My.css" rel="stylesheet" type="text/css">
</head>
样式应用顺序:
.nick {
color: yellow !important;
}
基本选择器:
1.通用元素选择器
* 表示应用到所有的标签。
* {color: yellow}
2.标签选择器
匹配所有使用 div 标签的元素(可以匹配所有标签)
div {color: yellow}
3.类选择器
匹配所有class属性中包含info的元素。
语法:.类名{样式}(类名不能以数字开头,类名要区分大小写。)
.Mycolor {color: yellow}
<h3 class="Mycolor">nick</h3>
4.ID选择器
使用id属性来调用样式,在一个网页中id的值都是唯一的(是W3C规范而不是规则,所以不会报错)。
语法:#ID名{样式}(ID名不能以数字开头)
#Mycolor {color: yellow}
<h3 id="Mycolor">Nick.</h3>
组合选择器:
1.多元素选择器
同时匹配h3,h4标签,之间用逗号分隔。
h3,h4 {color: yellow;}
<h3>Nick</h3>
<h4>Jenny</h4>
2.后代元素选择器
匹配所有div标签里嵌套的P标签,之间用空格分隔。
div p {color: yellow;}
<div>
<p>Nick</p>
<div>
<p>Nick</p>
</div>
</div>
3.子元素选择器
匹配所有div标签里嵌套的子P标签,之间用>分隔。
div > p {color: yellow;}
<div>
<p>Nick</p>
<p>Nick</p>
</div>
4.毗邻元素选择器
匹配所有紧随div标签之后的同级标签P,之间用+分隔(只能匹配一个)。
div + p {color: yellow;}
<div>Nick</div>
<p>Nick</p>
属性选择器:
1.[title] & P[title]
设置所有具有title属性的标签元素;
设置所有具有title属性的P标签元素。
[title]
{
color: yellow;
}
p[title]
{
color: yellow;
}
<div title>Nick</div>
<p title>Nick</p>
2.[title=Nick]
设置所有title属性等于“Nick”的标签元素。
[title="Nick"]
{
color: yellow;
}
<p title="Nick">Nick</p>
3.[title~=Nick]
设置所有title属性具有多个空格分隔的值、其中一个值等于“Nick”的标签元素。
[title~="Nick"]
{
color: yellow;
}
<p title="Nick Jenny">Nick</p>
<p title="Jenny Nick">Nick</p>
4.[title|=Nick]
设置所有title属性具有多个连字号分隔(hyphen-separated)的值、其中一个值以"Nick"开头的标签元素。
例:lang属性:"en"、"en-us"、"en-gb"等等
[title|="Nick"]
{
color: yellow;
}
<p title="Nick-Jenny">Nick</p>
5.[title^=Nick]
设置属性值以指定值开头的每个标签元素。
[title^="Nick"]
{
color: yellow;
}
<p title="NickJenny">Nick</p>
6.[title$=Nick]
设置属性值以指定值结尾的每个标签元素。
[title$="Nick"]
{
color: yellow;
}
<p title="JennyNick">Nick</p>
7.[title*=Nick]
设置属性值中包含指定值的每个元素
[title*="Nick"]
{
color: yellow;
}
<p title="SNickJenny">Nick</p>
伪类选择器:
1. link、hover、active、visited
a:link{color: black}
a:hover{color: yellow}
a:active{color: blue}
a:visited{color: red}
<a href="#">Nick</a>
2. before、after
p {
color: yellow;
}
p:before{
content: "before...";
}
p:after{
content: "after...";
}
<p> Nick </p>
1. 颜色属性:
color
transparent
opacity
2. 字体属性:
font-style: 用于规定斜体文本
font-weight: 设置文本的粗细
font-size: 设置字体的大小
font-family:字体名称
font:简写属性
3. 文本属性:
white-space: 设置元素中空白的处理方式
direction: 规定文本的方向
text-align: 文本的水平对齐方式
line-height: 文本行高
vertical-align: 文本所在行高的垂直对齐方式
text-indent: 文本缩进
letter-spacing: 添加字母之间的空白
word-spacing: 添加每个单词之间的空白
text-transform: 属性控制文本的大小写
text-overflow: 文本溢出样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
<style>
div {
width: 100px;
height: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div>索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁 索宁</div>
</body>
</html>
text-decoration: 文本的装饰
text-shadow:文本阴影
word-wrap:自动换行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
p {
width: 150px;
height: 160px;
background-color: #FFA500;
/*边框阴影*/
box-shadow: 10px 10px 5px #888;
/*自动换行*/
word-wrap: break-word;
}
h1 {
text-shadow: 5px 5px 5px #888;
}
</style>
</head>
<body>
<p>
When you are old and grey and full of sleep,And nodding by the fire, take down this book,And slowly read, and dream of the soft look
</p>
<h1>索宁</h1>
</body>
</html>
a {
text-decoration: none;
/*去除a标签下划线*/
}
4. 背景属性
background-color: 背景颜色
background-image 设置图像为背景
background-position 设置背景图像的位置坐标
background-repeat 设置背景图像不重复平铺
background-attachment 背景图像是否固定或者随着页面的其余部分滚动
background 简写
5. 列表属性
list-style-type: 列表项标志的类型
list-style-image:将图象设置为列表项标志
list-style-position:列表项标志的位置
list-style:缩写
1. 边框
border-style:边框样式
border-color:边框颜色
border-width:边框宽度
border-radius:圆角
border: 简写
box-shadow:边框阴影
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
border:2px solid;
border-radius:25px;
width: 140px;
}
</style>
</head>
<body>
<div>
点赞哦!dear.
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.radius1 {
display: inline-block;
width: 100px;
height: 100px;
background-color: yellow;
border-radius: 20px;
}
.radius2 {
display: inline-block;
width: 100px;
height: 100px;
background-color: red;
border-radius: 20px 35px;
}
.radius3 {
display: inline-block;
width: 100px;
height: 100px;
background-color: blue;
border-radius: 20px 35px 50px;
}
.radius4 {
display: inline-block;
width: 100px;
height: 100px;
background-color: green;
border-radius: 20px 35px 50px 60px;
}
</style>
</head>
<body>
<div>
<span class="radius1"></span>
<span class="radius2"></span>
<span class="radius3"></span>
<span class="radius4"></span>
</div>
</body>
</html>
边框实现各种三角符号:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.triangle-one {
display: inline-block;
border-top: 50px red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-two {
display: inline-block;
border-top: 0 red solid;
border-right: 50px green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-stree {
display: inline-block;
border-top: 50px red solid;
border-right: 0 green solid;
border-bottom: 50px yellow solid;
border-left: 50px blue solid;
}
.triangle-four {
display: inline-block;
border-top: 50px red solid;
border-right: 0 green solid;
border-bottom: 0 yellow solid;
border-left: 50px blue solid;
}
.triangle-five {
display: inline-block;
border: 50px transparent solid;
border-top: 50px red solid;
}
.triangle-six {
display: inline-block;
border: 50px transparent solid;
border-bottom: 50px yellow solid;
}
.triangle-seven {
display: inline-block;
border: 50px transparent solid;
border-top: 60px red solid;
border-right: 0;
}
.triangle-eight {
display: inline-block;
border: 50px transparent solid;
border-left: 30px yellow solid;
border-bottom: 0;
}
</style>
</head>
<body>
<div class="triangle-one"></div>
<div class="triangle-two"></div>
<div class="triangle-stree"></div>
<div class="triangle-four"></div>
<div class="triangle-five"></div>
<div class="triangle-six"></div>
<div class="triangle-seven"></div>
<div class="triangle-eight"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.back {
width: 1000px;
height: 1000px;
margin: 0 auto;
background-color: #ddd;
position: relative;
}
.back-in {
position: absolute;
width: 1020px;
height: 45px;
left: -20px;
top: 50px;
background-color: #2F4F4F;
}
.back-img {
border: 20px solid transparent;
border-top: 10px solid dimgrey;
border-right: 0;
display: inline-block;
position: absolute;
top: 95px;
left: -20px;
}
.back-font {
line-height: 9px;
margin-left: 30px;
color: white;
}
</style>
</head>
<body>
<div class="back">
<div class="back-in"><h3 class="back-font">妹子求关注 ^.^</h3></div>
<div class="back-img"></div>
</div>
</body>
</html>
2.★ 盒子模型
一个标准的盒子模型:
padding:用于控制内容与边框之间的距离;
margin: 用于控制元素与元素之间的距离;
一个参数,应用于四边。
两个参数,第一个用于上、下,第二个用于左、右。
三个参数,第一个用于上,第二个用于左、右,第三个用于下。
边框在默认情况下会定位于浏览器窗口的左上角,但是并没有紧贴着浏览器的窗口的边框,这是因为body本身也是一个盒子,外层还有html,
在默认情况下,body距离html会有若干像素的margin,所以body中的盒子不会紧贴浏览器窗口的边框了。
解决方法:
body {
margin: 0;
}
3.★ display
4. visibility
5.★ float 浮动
让一行显示两个块级标签,会脱离文档流
clear 清除浮动:
6. clip 剪裁图像
rect 剪裁定位元素:
7. overflow 设置当对象的内容超过其指定高度及宽度时如何显示内容
8.★ position 规定元素的定位类型
9. z-index 元素层叠顺序
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.z-index1 {
width: 100px;
height: 100px;
background-color: yellow;
position: absolute;
z-index: -1;
}
.z-index2 {
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top: 20px;
left: 20px;
z-index: 5;
}
</style>
</head>
<body>
<div class="z-index1"></div>
<div class="z-index2"></div>
</body>
</html>
10. outline 边框轮廓
11. zoom 缩放比例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.zoom1 {
zoom: 100%;
}
.zoom2 {
zoom: 150%;
}
.zoom3 {
zoom: 200%;
}
</style>
</head>
<body>
<div class="zoom1">Nick 100%</div>
<div class="zoom2">Nick 200%</div>
<div class="zoom3">Nick 300%</div>
</body>
</html>
12. cursor 鼠标的类型形状
鼠标放在以下单词上,There will be a miracle:
url: 自定义光标
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--<link href="cc2.css" rel="stylesheet" type="text/css">-->
<style>
body {
cursor: url("mouse.png"), auto;
/*图片地址:http://images.cnblogs.com/cnblogs_com/suoning/845162/o_mouse.png*/
}
</style>
</head>
<body>
<div><img src="http://images.cnblogs.com/cnblogs_com/suoning/845162/o_ns.png" height="100%" width="100%"></div>
</body>
</html>
Auto: 默认
Default: 默认
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
Crosshair
Pointer
Move
text
wait
help
not-allowed
13. transform、transition 动画效果
transform 转换,变形
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nick</title>
<meta charset="utf-8" />
<style type="text/css">
div {
border: 1px solid black;
height: 30px;
width: 30px;
background-color: yellow;
/*transform-origin: 50px 50px;*/
transform-origin: left;
transform: rotate(50deg);
/*transform: skew(50deg,50deg);*/
/*transform: translate(50px,50px);*/
/*transform: scale(2);*/
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Transition 平滑过渡
#property 指定属性对应类型
1、color: 通过红、绿、蓝和透明度组件变换(每个数值单独处理),如:background-color,border-color,color,outline-color等CSS属性;
2、length:真实的数字,如:word-spacing,width,vertical- align,top,right,bottom,left,padding,outline-width,margin,min-width,min- height,max-width,max-height,line-height,height,border-width,border- spacing,background-position等属性;
3、percentage:真实的数字,如:word-spacing,width,vertical- align,top,right,bottom,left,min-width,min- height,max-width,max-height,line-height,height,background-position等属性;
4、integer 离散步骤(整个数字),在真实的数字空间,以及使用floor()转换为整数时发生,如:outline-offset,z-index等属性;
5、number真实的(浮点型)数值,如:zoom,opacity,font-weight等属性;
6、transform list。
7、rectangle:通过x、 y、 width和height(转为数值)变换,如:crop;
8、visibility:离散步骤,在0到1数字范围之内,0表示“隐藏”,1表示完全“显示”,如:visibility;
9、shadow:作用于color、x、y、和blur(模糊)属性,如:text-shadow;
10、gradient:通过每次停止时的位置和颜色进行变化。它们必须有相同的类型(放射状的或是线性的)和相同的停止数值以便执行动画,如:background-image;
11、paint server (SVG):只支持下面的情况:从gradient到gradient以及color到color,然后工作与上面类似;
12、space-separated list of above:如果列表有相同的项目数值,则列表每一项按照上面的规则进行变化,否则无变化;
13、a shorthand property:如果缩写的所有部分都可以实现动画,则会像所有单个属性变化一样变化。
#支持执行transition效果的属性
Property Name Type
background-color as color
background-position as repeatable list of simple list of length, percentage, or calc
border-bottom-color as color
border-bottom-width as length
border-left-color as color
border-left-width as length
border-right-color as color
border-right-width as length
border-spacing as simple list of length
border-top-color as color
border-top-width as length
bottom as length, percentage, or calc
clip as rectangle
color as color
font-size as length
font-weight as font weight
height as length, percentage, or calc
left as length, percentage, or calc
letter-spacing as length
line-height as either number or length
margin-bottom as length
margin-left as length
margin-right as length
margin-top as length
max-height as length, percentage, or calc
max-width as length, percentage, or calc
min-height as length, percentage, or calc
min-width as length, percentage, or calc
opacity as number
outline-color as color
outline-width as length
padding-bottom as length
padding-left as length
padding-right as length
padding-top as length
right as length, percentage, or calc
text-indent as length, percentage, or calc
text-shadow as shadow list
top as length, percentage, or calc
vertical-align as length
visibility as visibility
width as length, percentage, or calc
word-spacing as length
z-index as integer
鼠标放在以下图片上,There will be a miracle:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>nick</title>
<meta charset="utf-8" />
<style type="text/css">
.img-see-2016-7-2 {
background-image: url("http://images.cnblogs.com/cnblogs_com/suoning/845162/o_sea.jpg");
background-size: 660px;
background-repeat: no-repeat;
height: 300px;
width: 600px;
transition-duration: 30s;
transition-timing-function: ease;
transition-property: background-size;
}
.img-see-2016-7-2:hover {
background-size: 2000px;
}
</style>
</head>
<body>
<div class="img-see-2016-7-2"></div>
</body>
</html>
作者:suoning
原文链接:https://www.cnblogs.com/suoning/p/5625582.html
ue 横向滚动
<div class="slide-box">
<div class="slide-within">
<div class="slide-item" v-for="(item,index) in listData" :key="index">{{ index + item.label }}</div>
</div>
</div>
.slide-box {
margin-top: 200px;
overflow: hidden;
}
.slide-within {
display: -webkit-box;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
padding-bottom: 10px;
margin-bottom: -10px;
}
.slide-item {
width: 200px;
height: 200px;
border: 1px solid #ccc;
margin-right: 30px;
}
js 代码
家好,我是四川新华电脑学院小张,
这篇文章讲解Html的相关知识,如果想从零开始学习php编程的小伙伴,请从淼哥的第一篇文章看!
上次文章讲解的是DTD,也就是我们常说的DOCTYPE。
我们继续讲解。
<!DOCTYPE html>-------------------------DOCTYPE 声明了文档类型
<html> ------------------------------------文档类型html开始标记
<head> -----------------------------------头部标记
<title>我的第一个标题</title>
</head> ----------------------------------头部结束标记
<body> ---------------------------------文件主体
<h1>我的第一个标题</h1>
<p>我的第一个段落。</p>
</body> ----------------------------------文件主体结束
</html> ----------------------------------文档类型html结束标记
这个是我们上次讲解的html架构。
接着我们继续讲解。
html标签
•写法<html></html>
HTML标签是HTML文档的根标签,在HTML中标签是一层嵌套一层的,而<HTML>标签是根标签(最外面一层的标签),所有其他的标签都写在这个标签中。
根标签我们可以理解为最外层的标签。(看上面的结构)
文档头信息
HTML又包含head标签和body标签,其中head标签中设置文档头信息,body标签中设置文档的内容。
<head> 标签用于定义文档的头部,它是所有头部元素的容器。
<head> 中的元素可以引用脚本、指示浏览器在哪里找到样式表、提供元信息等等。
下面这些标签可用在 head 部分:<base>, <link>, <meta>, <script>, <style>, 以及 <title>。
那么怎么理解元信息呢?比如对于网页本身的一些描述,该网页的标题?该网页的描述,该网页用的什么字符编码!等等,这些信息描述着网页,用户又看不到这些信息。
比如某个人的性别,姓名,当你看到这个人,可以看到外貌,身高,穿衣服的颜色。但是你并不知道这个人的姓名,有的也不知道性别。尤其像某些中性一点的长相。是吧。元信息不会渲染,但是属于该网页的信息。
base标签
(该标签应该学习了a img link form这几个标签之后在学习,看不懂没关系,可以先了解)
base标签,是嵌套在head标签中的一个标签。这个标签是一个可选标签,也就是可以有,也可以没有!
<base> 标签为页面上的所有链接规定默认地址或默认目标。
通常情况下,浏览器会从当前文档的 URL 中提取相应的元素来填写相对 URL 中的空白。比如:我有个<a href='aa.html'>标签,那么浏览器会从当前文档的url,比如当前文档的url是www.xxxx.com/aa/bb/cc.html,浏览器会把www.xxxx.com/aa/bb/路径拿出来,和aa.html组成新的url,那么这个超链接就会变成www.xxxx.com/aa/bb/aa.html。
使用 <base> 标签可以改变这一点。
如果我们将base设置成为其他的url。<base href="http://www.myweb.com/i/" />那么,还是<a href='aa.html'>标签,就会把http://www.myweb.com/i/这个路径拿出来和aa.html组成新的url地址。那么这个url超链接就会变成http://www.myweb.com/i/a.html这个链接了。
浏览器随后将不再使用当前文档的 URL,而使用指定的基本 URL 来解析所有的相对 URL。这其中包括 <a>、<img>、<link>、<form> 标签中的 URL。
base标签的用法
<base href="http://www.myweb.com/i/" /> ------必选属性。(你有这个标签,就必须拥有这个属性)
<base target="_blank" /> ------------------可选属性。target意思是目标,打开超链接的方式,
当然也可以将两个属性写到一个base标签中。
<base href="http://www.myweb.com/i/" target="_blank"/>
默认target的属性是_self,也就是点击超链接,在当前页面的框架中打开。(为什么不是当前页面呢?因为页面有可能嵌套在框架里)
link标签
<link> 标签定义文档与外部资源的关系。 也就是说定义外部CSS文件存放的位置。因为如果将CSS全部写在网页中,这样显的页面太乱,一般都是单独存放在一个CSS 文件中的。
<link> 标签最常见的用途是链接样式表CSS。
用法: <head> <link rel="stylesheet" type="text/css" href="test.css"></head>
meta标签
<meta> 元素可提供有关页面的元信息(meta-information),针对搜索引擎和更新频度的描述和关键词。
<meta> 标签位于文档的头部,不包含任何内容。
<meta> 标签的属性定义了与文档相关联的名称/值对。
meta标签的作用有:搜索引擎优化(SEO),定义页面使用语言,自动刷新并指向新的页面,实现网页转换时的动态效果,控制页面缓冲,网页定级评价,控制网页显示的窗口等!
由于meta信息相对比较复杂我们将在以后HTML高级课程中讲解
最常用meta标签是:
<meta charset=“utf-8”/>
设置页面编码写法。(页面编码注意,要设置的编码和文档的编码统一,否则会出乱码)
具体编码以后的文章讲解。
script标签
<script> 标签用于定义客户端脚本,比如 JavaScript。
script 元素既可以包含脚本语句,也可以通过 src 属性指向外部脚本文件。
必需的 type 属性规定脚本的 MIME 类型。
JavaScript 的常见应用是图像操作、表单验证以及动态内容更新。
用法<script type="text/javascript">document.write("Hello World!") ></script> 以后学javascript将会用到,这里只做了解。
style标签
<style> 标签用于为 HTML 文档定义样式信息。(内联CSS样式)
在 style 中,您可以规定在浏览器中如何呈现 HTML 文档。
type 属性是必需的,定义 style 元素的内容。唯一可能的值是 "text/css"。
用法<head> <style type="text/css"> h1 {color:red} p {color:blue} </style> </head>
该标签将会在学习CSS时用到,这里只做了解
title标签
<title> 元素可定义文档的标题。
浏览器会以特殊的方式来使用标题,并且通常把它放置在浏览器窗口的标题栏或状态栏上。
同样,当把文档加入用户的链接列表或者收藏夹或书签列表时,标题将成为该文档链接的默认名称。
用法<title>网页标题</title>
<title> 标签是 <head> 标签中唯一要求包含的东西。(必须有title标签)
head 标签总结
<head>标签唯一要求包含的标签是<title>其他那几种可以包含也可以不包含,但是一般我们会包含<meta charset=“utf-8”>告诉浏览器我们的文件编码是什么。
常用的标签有:
<meta name=“keywords” content=“关键字”>告诉搜索引擎这个页面的关键字
<meta name=“description” content=“页面介绍”>告诉搜索引擎这个页面的简介
meta标签,会在Html高级部分继续讲解。
<body>页面主体信息
body 元素包含html的所有显示web内容(比如文本、超链接、图像、表格和列表等等。)
Body中可以使用块级标签和内联标签来显示文档结构
块级标签:h1~h6,p,div,table,ul,dl,from标签等
内联标签:a,img,span,I,strong,select标签等
什么块级标签(元素)呢?块级标签和内联标签区别是什么?
块级元素(block)特性:总是独占一行
内联元素(inline)特性:和相邻的内联元素在同一行。
标签和元素是一个意思!
<body>中包含的标签?
标题标签
通过<h1>~<h6>六个标签定义不同大写的标签。
文本格式化标签
早期编写html代码的时候,那个时候css用的很少,所以有一些标签来文本格式化。现在基本都用CSS来格式化文本的大小颜色粗体等等。
而更多时候使用这些标签来进行占位,利用CSS来渲染这些标签。常用的是span。
html中的注释
注释用来说明、注解、注释代码。给人看的不会被执行。
格式为:<!– 注释内容-->
浏览器页面不会被显示,而页面源代码中可以看到注释的内容。因为项目越大,或者你的页面越大,当时可能你能看懂。时间长了肯定看不明白。如果有注释的话,可以马上理解当时为什么要这么做。
水平线
在HTML代码中加入一条水平线利用<hr />来操作。
段落标签-<p>
浏览器会自动地在段落的前后添加空行,一般用在大段的文章。
换行标签<br/>
<br/>标签可以实现换一个新行 ,正常来说,你在编写html页面的时候,无论怎么换行,在页面用浏览器打开的时候,是不会换行的,如果加入了<br/>标签,浏览器就会认为这里该换行显示了。
链接<a>标签
HTML 使用超级链接与网络上的另一个文档相连。
几乎可以在所有的网页中找到链接。点击链接可以从一张页面跳转到另一张页面。
超链接可以是一个字,一个词,或者一组词,也可以是一幅图像,您可以点击这些内容来跳转到新的文档或者当前文档中的某个部分。
当您把鼠标指针移动到网页中的某个链接上时,箭头会变为一只小手。
我们通过使用 <a> 标签在 HTML 中创建链接。
有两种使用 <a> 标签的方式:
1、通过使用 href 属性 - 创建指向另一个文档的链接
<a href=“链接的文件名” target=“_blank”>链接名</a>
2、通过使用 name 属性 - 创建文档内的书签
一般锚点链接主要用于网页太长了,想浏览的那个位置需要滚轮滚动好几下才能到达那个位置,而使用锚点(书签)直接可以准确的跳转到你想去的位置。
<a name=“文档标签名”>文档标签</a>
文档中对锚进行命名(创建一个书签)
<a href=“#tips”>链接名</a>
同一个文档中创建指向该锚的链接用关键字#+锚名字
<a href="http://www.xxx.com.cn/html/html_links.asp#tips">有用的提示</a>
也可以链接到其他网络上的页面锚的链接
图像<img>
可以使用img标签在页面上显示一张图片。
格式:
<img src=“图片路径” width=“宽” height=“高” alt=“图片无法显示时的提示”title=“鼠标放图片上的提示”/>
备注:一般只设置宽即可,浏览器会根据图片大小进行缩放。如果强行设置宽、高,有的时候图片会失真。
列表标签
列表标签分为有序标签和无序标签
当然、有序列表前面也可以更改序号,需要在CSS中学习改变序号的方法。
二级列表<dl>标签
表格标签-table
Table标签用来制作表格,表格由若干个行<tr>组成,每一行又由若干个单元格<td>组成。
Table标签中使用tr标签定义行,td标签定义一行中的一个列。如:定义一个一行四列。
表格的表头使用 <th> 标签进行定义。
大多数浏览器会把表头显示为粗体居中的文本:
<table>标签的cellpadding 属性规定单元边沿与其内容之间的空白。
<table>标签的cellspacing 属性规定单元格之间的空间。
横向合并单元格-colspan
表格-table-竖向-rowspan
内联框架
可以使用iframe在页面中在嵌入另外一个页面。
分区标签-div
Div是块级标签,主要是用来作为标签容器,和规划页面结构(页面布局)的
用法:
<div style="margin:auto;border:1px solid #f00;width: 300px;height: 600px"></div>
在很早以前,小编刚入行的时候,那个时候CSS不流行,页面布局全部都用表格来做。那酸爽实在无法用言语来表达。而现在都是用CSS来进行页面布局。这个div标签页是以后布局常用的标签。
Span标签
Span标签是内联标签,没有特殊功能。主要是用来做为文本的容器,span标签主要是配合CSS来处理文字。
比如,我只想让几个文字编程红颜色的,这个时候就可以用span标签配合CSS来做了。
框架集-frameset
我们可以使用frameset标签把一个页面窗口分隔成多个窗口,然后使用frame标签为每一个窗口制定一个页面
使用rows/cols的值规定每行或每列占据屏幕的面积,中间用逗号分隔。
frameset不能放在body中,如果放在body中不能显示框架 !
在最新的html5中已经删除了这个标签了
实体
在 HTML 中,某些字符是预留的。
在 HTML 中不能使用小于号(<)和大于号(>),这是因为浏览器会误认为它们是标签。
比如我们想在网页使用空格,直接按空格键是肯定不好使的,所以使用使用实体 !
音频
<embed src="helloworld.swf" height=“100” width=“100”/>
<embed> 标签是 HTML 5 中的新标签。
使用embed标签可以在网页中嵌入Flash,Mid,MP3等嵌入式内容
现在html5出了很多新的标签,以后会专门有讲解html5的文章。
今天我们一起了解了html相关的很多标签。其实都很简单。只要自己动手做一做,就可以做出来了。如果想要做出精美的页面,还是需要配合css来实现的哦。
明天我们继续讲解html的一些其他相关知识。手写不宜!请给小编点个赞!十分感谢。
*请认真填写需求信息,我们会在24小时内与您取得联系。