内容复习:如何能够是一段文字独占一行,同时也能够又加粗有些题展示呢?采用标签嵌套的方式来解决,示例源代码如下:
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
<
p
>
<
strong
>
<
em
>This is an example.
</
em
>
</
strong
>
</
p
>这是一段“独占一行”功能的测试文本。
</
body
>
</
html
>
如何来验证是否是独占了一行呢,那么可以在尾标签后面直接添加一串字符,查看是否和前面文字分段显示。
新知识内容:
如何在浏览器页面所显示的文字中插入多个空格字符?使用一个<div>标签设置一个容器,然后网容器中填入英文字符串与中文字符,会发现英文字符串到达容器边界不会换行,而中文字符到达边界后会自动的换行,这是问什么?
浏览器无法识别英文单词,只能识别字母,“空格”,英文单词分隔符;回车符,也是和空格的作用是一样;
空格文本的展示形式;HTML编码表示特殊字符。
比较常用的还有两个:<div>
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
接 下来,我给大家讲解一个新标签,叫<div>
</
body
>
</
html
>
那么如何输出回车字符呢?<br>标签,单标签。<hr>标签,水平线。
order list,有序列表<ol></ol>与<li></li>标签,二者配合使用;其中<ol>标签有一个type属性,它有五种值,对应五种排序方式,分别为1,a,A,i,I;注意这里的i与I所表示的是罗马数字,并非字母。比如,如果使用type=“A”,那么将会使用大些的英文字母作为有序排列,如果超过了26个列表项后,会出现27进制;还有一个reversed属性,示例源代码如下:
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
你们喜欢看的电影
<
ol
type=
"A"
reversed=
"reversed"
>
<
li
>marvel
</
li
>
<
li
>速8
</
li
>
<
li
>返老还童
</
li
>
<
li
>了不起的盖茨比
</
li
>
</
ol
>
</
body
>
</
html
>
如果排序时,不希望从1开始,比如从3开始排序,可使用start属性,将其值赋为3即可;但需要注意的是,其中start属性所填写的值必须为“第几个开始”,比如采用小写罗马字符进行有序排列,那么type="i" start="3",如此这样,那么第一个列表项将会从Ⅲ开始,示例源代码如下:
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
你们喜欢看的电影
<
ol
type=
"1"
start=
"3"
>
<
li
>marvel
</
li
>
<
li
>速8
</
li
>
<
li
>返老还童
</
li
>
<
li
>了不起的盖茨比
</
li
>
</
ol
>
</
body
>
</
html
>
这对有序标签在实际应用开发中基本没什么用!但是他的兄弟,<ul></ul>与<li></li>标签,却有很大的用处。一个大的功能有很多功能子项来构成,每一个功能子项和它的功能和样式基本上都是相同的,可能内容有些小小的差异,这么多的功能子项组成了这样的一个大功能,最好使用<ul></ul>与<li></li>标签来展现,更符合它天生的结构,更符合它的父子结构。比如柜子与抽屉的关系;实际web应用开发中,导航栏的开发,导航栏包含很多菜单项,每一个菜单项是一个功能子项,功能和展示形式基本一样,只不过内容稍有不同,其中<ul>标签的属性type的取值可以为discircle,square,circle等;
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
<
ul
type=
"circle"
>
<
li
>草莓
</
li
>
<
li
>苹果
</
li
>
<
li
>橙子
</
li
>
</
ul
>
</
body
>
</
html
>
HTML语句是最基本的“楼”的架子,装修主要由CSS来负责;示例模拟了一下淘宝网页中的部分导航栏功能,示例源代码如下:
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
<
style
>
*{
margin:
0px;
padding:
0px;
}
ul{
list-style:none;
}
li{
margin:
0px
10px;
float:left;
color:#f40;
font-size:
14px;
font-weight:bold;
height:
25px;
line-height:
25px;
padding:
0px
5px;
}
li:hover{
background-color:#f40;
color:#fff;
border-radius:
15px;
}
a{
color:#f40;
text-decoration:none;
}
a:hover{
color:#fff;
}
<
/
style
>
</
head
>
<
body
>
<
ul
>
<
li
>
<
a
href=
"https://qiang.taobao.com"
>海抢购
</
a
>
</
li
>
<
li
>电器城
</
li
>
<
li
>司法拍卖
</
li
>
<
li
>中国质造
</
li
>
<
li
>兴农扶贫
</
li
>
</
ul
>
</
body
>
</
html
>
<img>标签,是一个单标签,具有一个src属性,其值为:1.网上的url;2.本地的绝对路径;3.本地的相对路径;
它的其他属性,如alt属性,图片占位符;这个属性用于图片不能正常展示时或者没能正常加载出来,图片出错没能显示出来,可以使用文字来简单叙述一下,是用来容错。
title属性,图片提示符;
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
<
img
src=
"微信图片_20180621103739.jpg"
alt=
"this is a handsome man."
style=
"width:250px"
title=
"this is a handsome man.i think you will like him."
>
</
body
>
</
html
>
anchor,锚,<a>标签,超级链接;它的href属性,HyperText reference,超文本引用,它的值为跳转链接,指向目标地址;<a>标签内部可以包裹任何东西,比如当你放入一张图片的时候,它就具有了跳转链接的作用;可以添加CSS行间样式;
是否可以在新的标签页内打开链接?可以加入target属性,赋值为_blank即可;
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
<
style
>
/* *{
margin:0px;
padding:0px;
} */
a{
line-height:
100px;
text-decoration:none;
color:#fff;
}
<
/
style
>
</
head
>
<
body
>
<
a
href=
"https:www.baidu.com"
style=
"width:100px;height:100px;
background-color:red;display:block;"
target=
"_blank"
>
<
img
src=
"https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=458756119,112096367
&
fm=27
&
gp=0.jpg"
alt=
"美胸"
title=
"这个美胸不错吧!"
>
</
a
>
</
body
>
</
html
>
<a>标签的第二个作用:作为锚点,记录一个位置,可以通过该标签回到该位置;可以加入position属性,当赋值为fixed时,那么就会出现固定在窗口区域的某一个固定位置。
<a>标签的第三个作用:在移动端网页中具备打电话,发邮件等功能;<a href="tel:25257758">给志勇大帝拨打电话</a>;如果是发邮件,那么href="mailto:popohopo@163.com"
<a>标签的第四个作用:协议限定符,具有一定的黑客功能;没有太大的实际应用;<a href="javascript:while(1){alert('让你手贱')}">你点我试试看呀,come on,来呀!</a>
最后一个标签,很重要!表单标签<form></form>标签,它能够发送数据给后端工程师;method属性,发送方式,它的赋值有两种,get与post;action属性,发送给谁,“谁”的地址,后端的地址;它里面还需要一些组件,<input>标签,type属性,决定<input>标签能够长成什么样子,取值可以为text或password,submit,radio等;
发送数据必须有两个值,一个是数据名,一个是数据值(数据内容),此二者缺一不可。是否提交成功,如何判断?
密码框,只对用户自己不可见,给你用户自己一个心理安慰。
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
<
form
method=
"get"
action=
""
>
<
p
>
username:
<
input
type=
"text"
name=
"username"
>
</
p
>
<
p
>
password:
<
input
type=
"password"
name=
"password"
>
</
p
>
<
input
type=
"submit"
value=
"点我试试看,登陆吧"
>
</
form
>
</
body
>
</
html
>
单选框与复选框的展示:
如何是单选当中的多个选择框属于同一道题?可以通过name属性名称来设置;
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
<
form
method=
"get"
action=
""
>
我们所喜欢的男明星:
<
p
style=
"border:2px solid red; padding-left:25px;"
>
<
input
type=
"radio"
name=
"star"
value=
"小贝"
>贝克汉姆
</
p
>
<
p
>
<
input
type=
"radio"
name=
"star"
value=
"小莱"
>莱昂纳多
</
p
>
<
p
>
<
input
type=
"radio"
name=
"star"
value=
"handsome"
>志勇大帝
</
p
>
<
input
type=
"submit"
value=
"提交"
>
</
form
>
</
body
>
</
html
>
登陆界面中,当聚焦或者失去焦点后,输入框中的文字变化情况的模拟,示例源代码如下:
<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
content=
"这是一件你穿了就不想脱的衣服"
name=
"description"
>
<
title
>淘宝网,淘,我喜欢!
</
title
>
</
head
>
<
body
>
<
form
method=
"GET"
action=
""
>
<
P
>username:
<
input
type=
"text"
name=
"username"
value=
"请输入用户名"
style=
"color:#999"
onfocus=
"if(this.value == '请输入用户名'){this.value = ''; this.style.color = '#424242';console.log(this);}"
onblur=
"if(this.value == ''){this.value = '请输入用户名'; this.style.color = '#999';}"
>
</
P
>
<
P
>password:
<
input
type=
"password"
name=
"password"
>
</
P
>
<
input
type=
"submit"
value=
"提交"
>
</
form
>
</
body
>
</
html
>
在这里用到了一些JavaScript代码,在查看这里的this到底指代的是谁的时候,可以使用console.log()函数进行输出处理;