Web前端 第五周

四、拓展HTML

1.strong与b、em与i

表现形态:都是文本加粗文本斜体

<body>
    <strong>文本1</strong>
    <b>文本2</b>
    <em>文本3</em>
    <i>文本4</i>
</body>

在这里插入图片描述

区别:strong和em是具备语义化的,而b和i是不具备语义化的

2.引用标签

  • blockquote:引用大段的段落解释
<body>
    <p>
        <abbr title="World Health Organization">WHO</abbr>成立于1948年。
    </p>
</body>

在这里插入图片描述

  • q :引用小段的短语解释
  • abbr :缩写或首字母缩略词
  • address :引用文档地址信息
  • cite :引用著作的标题

3.iframe嵌套页面

iframe元素会创建包含另一个文档的内联框架(即行内框架)
可以引入其他的html到当前html中显示
在这里插入图片描述

  • 主要是利用iframe的属性进行样式的调节
<body>
    <iframe src="https://www.taobao.com" frameborder="0" scrolling="no" width="400" height="400"></iframe>
</body>

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        iframe{width: 100%;height: 700px;}
    </style>
</head>
<body>
    <iframe src="https://www.taobao.com" frameborder="0" scrolling="no"></iframe>
</body>
</html>

在这里插入图片描述

  • 应用场景:数据传输、共享代码、局部刷新、第三方介入等。

4.br与wbr

  • br:换行
  • wbr:软换行

普通:

<p>
    ghjk kjiu ghjk jkui ghjk jkui ghjk kjiu ghjk jkui ghjk jkui
</p>

在这里插入图片描述
br:

<p>
    ghjk kjiu ghjk jkui ghjk jkui <br> ghjk kjiu ghjk jkui ghjk jkui
</p>

在这里插入图片描述

5.pre与code

针对网页中的代码显示效果。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
</html>

在这里插入图片描述

6.map与area

给特殊图形添加链接,area能添加的热区的形状:矩形、圆形、多边形。

7.embed与object

给flash和一些插件进行渲染操作的标签。

<body>
    <embed src="./img/flash.swf" type="">
</body>
<body>
    <object>
        <param name="movie" value="./img/flash.swf">
    </object>
</body>

注:object元素需要配合param元素一起完成

8.audio与video

引入音频与视频的标签,属于H5的功能。

9.文字注释与文字方向

  • 文字注释:ruby、rt这样一个组合
<body>
    <ruby><rt>hán</rt></ruby>
</body>

在这里插入图片描述

  • bdo标签可覆盖默认的文本方向
<body>
    <ruby><rt>hán</rt></ruby>
    <p>
    <bdo dir="ltr">高数</bdo>不定积分有理函数
    </p>
</body>

在这里插入图片描述

<body>
    <ruby><rt>hán</rt></ruby>
    <p>
    <bdo dir="rtl">高数</bdo>不定积分有理函数
    </p>
</body>

在这里插入图片描述

10.扩展link标签

添加网址标题栏的小图标:

<link rel="icon" type="/image/x-icon" href="http://www.mobiletrain.org/favicon.ico">
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="icon" type="/image/x-icon" href="http://www.mobiletrain.org/favicon.ico">
</head>
<body>
    
</body>
</html>

在这里插入图片描述
DNS预解析:

11.扩展meta标签

mata添加一些辅助信息。

12.HTML5新语义化标签

  • header:页眉
  • footer:页脚
  • main:主体
  • hgroup:标题组合
  • nav:导航

注:header、main、footer在一个网页中只能出现一次

  • article:独立的内容
  • aside:辅助信息的内容
  • section:区域
  • figure:描述图像或视频
  • figcaptain:描述图像或视频的标题部分
  • datalist : 选项列表
  • details / summary : 文档细节/文档标题
  • progress / meter : 定义进度条/定义度量范围
  • time :定义日期或时间
  • mark : 带有记号的文本
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <header>
        <hgroup>
            <h1>主标题</h1>
            <h2>副标题</h2>
        </hgroup>
        <nav>
            <ul>
                <li>首页</li>
                <li>论坛</li>
                <li>关于</li>
            </ul>
        </nav>
    </header>
    <main>
        <article>
            <section>
                <input type="text" list="elems">
                <details name="elems">
                    <option value="a"></option>
                    <option value="ab"></option>
                    <option value="apple"></option>
                    <option value="abandon"></option>
                    <option value="aside"></option>
                    <option value="awww"></option>
                </details>
                <details open>
                    <summary>HTML</summary>
                    <p>超文本标记语言</p>
                </details>
                <progress min="0" max="10" value="5"></progress>
                <meter min="10" max="100" value="80" low="10" high="60"></meter>
                <p>
                    今天是<time title="2-14">情人节</time>,街上人很多
                </p>
                <p>
                    今天是<mark>情人节</mark>,街上人很多
                </p>
                </section>
            <section>
                <ul>
                    <li>
                        <figure>
                            <img src="./img/youku.jpg" alt="">
                            <figcaption>
                                点燃我,温暖你
                                <br>
                                欢喜冤家互怼生情
                            </figcaption>
                        </figure>
                    </li>
                </ul>
            </section>
            <section>
                <ul>
                    <li>
                        <figure>
                            <img src="./img/youku.jpg" alt="">
                            <figcaption>
                                点燃我,温暖你
                                <br>
                                欢喜冤家互怼生情
                            </figcaption>
                        </figure>
                    </li>
                </ul>
            </section>
            <section>
                <ul>
                    <li>
                        <figure>
                            <img src="./img/youku.jpg" alt="">
                            <figcaption>
                                点燃我,温暖你
                                <br>
                                欢喜冤家互怼生情
                            </figcaption>
                        </figure>
                    </li>
                </ul>
            </section>
        </article>
        <aside></aside>
    </main>
    <footer></footer>
</body>
</html>

在这里插入图片描述

五、弹性布局

1.flex弹性布局

在这里插入图片描述

  • flex-direction

默认:

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    #box{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;}
    #box div{width: 50px;height: 50px;color: white;line-height: 50px;text-align: center;background: darkcyan;}
    </style>
</head>
<body>
    <div id="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
    </div>
</body>
</html>

在这里插入图片描述
row-reverse:

#box{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;flex-direction: row-reverse;}

在这里插入图片描述
colum:
在这里插入图片描述
colum-revers:
在这里插入图片描述

  • flex-wrap:用来控制子项整体单行显示还是换行显示

在这里插入图片描述
默认:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    #box2{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;}
    #box2 div{width: 50px;height: 50px;color: white;line-height: 50px;text-align: center;background: darkcyan;}
    </style>
</head>
<body>
    <div id="box2">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>1</div>
        <div>2</div>
    </div>
</body>
</html>

在这里插入图片描述
wrap:

#box2{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;flex-wrap: wrap;}

在这里插入图片描述
wrap-reverse:

#box2{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;flex-wrap: wrap-reverse;}

在这里插入图片描述

  • flex-flow:flex布局的flow流动特性。第一个值表示换行,第二个值表示空格,中间用隔开。
#box2{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;flex-flow: column;}

在这里插入图片描述
wrap:

#box2{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;flex-flow: column wrap;}

在这里插入图片描述

  • justfity-conten:决定了主轴方向上子项的对齐和分布方式。

在这里插入图片描述

默认:

 #box3{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;}

在这里插入图片描述

flex-end:

#box3{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;justify-content: flex-end;}

在这里插入图片描述
center:
在这里插入图片描述
space-around:
在这里插入图片描述
space-between:
在这里插入图片描述
space-evenly:
在这里插入图片描述

  • align-items:

在这里插入图片描述

<style>
    #box4{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;}
    #box4 div{width: 50px;height: 50px;background: darkcyan;}
    </style>

在这里插入图片描述
flex-star:

<style>
    #box4{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;justify-content: space-evenly;align-items: flex-start;}
    #box4 div{width: 50px;background: darkcyan;}
    </style>

在这里插入图片描述
center:
在这里插入图片描述
flex-end:
在这里插入图片描述

  • align-content

在这里插入图片描述

2.作用在flex子项上的CSS属性

在这里插入图片描述
flex-grow:

<style>
    #box{width: 300px;height: 300px;border:1px black solid;margin:20px auto;display: flex;}
    #box div{width: 50px;height: 50px;color: white;line-height: 50px;text-align: center;background: darkcyan;}
    #box div:nth-child(2){background: yellow;color: black;flex-grow: 1;}
    </style>

在这里插入图片描述
flex-shrink:

#box2 div:nth-child(2){background: yellow;color: black;flex-shrink: 0;}

在这里插入图片描述
flex-basis:

#box2 div:nth-child(2){background: yellow;color: black;flex-basis: 100px;}

在这里插入图片描述
flex:

#box2 div:nth-child(2){background: yellow;color: black;flex:0 1 auto;}

在这里插入图片描述

align-self:
在这里插入图片描述

3.Flex案例

  • 骰子的点数
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    #box1{width: 100px;height: 100px;border:1px black solid;border-radius: 5px;display: flex;justify-content: center;align-items:center;}
    #box1 div{width: 30%;height: 30%;background: black;border-radius: 50%;}

    #box2{width: 100px;height: 100px;border:1px black solid;border-radius: 5px;display: flex;justify-content:space-between;}
    #box2 div{width: 30%;height: 30%;background: black;border-radius: 50%;}
    #box2 div:last-child{align-self: flex-end;}

    #box3{width: 100px;height: 100px;border:1px black solid;border-radius: 5px;display: flex;justify-content:space-between;align-items: center;}
    #box3 div{width: 30%;height: 30%;background: black;border-radius: 50%;}
    #box3 div:first-child{align-self: flex-start;}
    #box3 div:last-child{align-self: flex-end;}

    #box4{width: 100px;height: 100px;border:1px black solid;border-radius: 5px;display: flex;flex-wrap: wrap;}
    #box4 div{width: 100%;display: flex;justify-content: space-between;}
    #box4 div:last-child{align-items: flex-end;}
    #box4 i{display: block;width: 30%;height: 60%;background: black;border-radius: 50%;}

    #box5{width: 100px;height: 100px;border:1px black solid;border-radius: 5px;display: flex;flex-wrap: wrap;}
    #box5 div{width: 100%;display: flex;justify-content: center;align-items: center;}
    #box5 div:first-child{align-items: flex-start;justify-content: space-between;}
    #box5 div:last-child{align-items: flex-end;justify-content: space-between;}
    #box5 i{display: block;width: 30%;height: 90%;background: black;border-radius: 50%;}

    #box6{width: 100px;height: 100px;border:1px black solid;border-radius: 5px;display: flex;flex-wrap: wrap;}
    #box6 div{width: 100%;display: flex;justify-content: space-between;}
    #box6 div:first-child{align-items: flex-start;}
    #box6 div:last-child{align-items: flex-end;}
    #box6 i{display: block;width: 30%;height: 90%;background: black;border-radius: 50%;}
    </style>
</head>
<body>
    <div id="box1">
        <div></div>
    </div>
    <div id="box2">
        <div></div>
        <div></div>
    </div>
    <div id="box3">
        <div></div>
        <div></div>
        <div></div>
    </div>
    <div id="box4">
        <div>
            <i></i>
            <i></i>
        </div>
        <div>
            <i></i>
            <i></i>
        </div>
    </div>
    <div id="box5">
        <div>
            <i></i>
            <i></i>
        </div>
        <div>
            <i></i>
        </div>
        <div>
            <i></i>
            <i></i>
        </div>
    </div>
    <div id="box6">
        <div>
            <i></i>
            <i></i>
        </div>
        <div>
            <i></i>
            <i></i>
        </div>
        <div>
            <i></i>
            <i></i>
        </div>
    </div>
</body>
</html>

在这里插入图片描述

  • 两列固定,一列自适应
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    *main{margin: 0;padding: 0;}
    #main{display: flex;}
    #left{width: 200px;height: 200px;background: khaki;}
    #center{flex: 1;height: 300px;background: cornflowerblue;}
    #right{width: 150px;height: 200px;background: darkolivegreen;}
    </style>
</head>
<body>
    <div id="main">
        <div id="left"></div>
        <div id="center"></div>
        <div id="right"></div>
    </div>
</body>
</html>

在这里插入图片描述

  • 百度弹性导航

4.Grid网格布局

二维布局方法,纵横两个方向总是同时存在
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .box{width: 500px;height: 500px;border: 1px gray dotted;display: grid;
        grid-template-rows: 100px auto 25%;
        grid-template-columns: 100px 100px 200px 100px;
    }
    </style>
</head>
<body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
        <div>7</div>
        <div>8</div>
        <div>9</div>
        <div>10</div>
        <div>11</div>
        <div>12</div>
    </div>
</body>
</html>

在这里插入图片描述

  • grid-template-colum和grid-template-rows

对网格进行横纵划分,形成二维布局。单位可以是像素,百分比,自适应以及fr单位(网格剩余空间比例单位)

注:如果需要添加多个横纵网格时,可以利用repeat()语法进行简化操作。

<style>
    .box{width: 300px;height: 300px;border: 1px gray dotted;display: grid;
        grid-template-rows:repeat(3,1fr);
        grid-template-columns:repeat(3,1fr);
    }
    </style>
  • grid-template-areas和grid-template

grid-template是grid-template-rows、grid-template-columns和grid-template-areas属性的缩写。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .box{width: 300px;height: 300px;border: 1px gray dotted;display: grid;
        grid-template-rows:repeat(3,1fr);
        grid-template-columns:repeat(3,1fr);
    }
    .box div{background: palevioletred;border: 1px black solid;}
    
    .box2{width: 300px;height: 300px;border: 1px gray dotted;display: grid;
        grid-template-rows:repeat(3,1fr);
        grid-template-columns:repeat(3,1fr);
        grid-template-areas: 
        "a1 a1 a1"
        "a2 a2 a3"
        "a2 a2 a3";
    }
    .box2 div{background: palevioletred;border: 1px black solid;}
    .box2 div:nth-child(1){grid-area: a1;}
    .box2 div:nth-child(2){grid-area: a2;}
    .box2 div:nth-child(3){grid-area: a3;}
    </style>
</head>
<body>
     <div class="box2">
        <div>1</div>
        <div>2</div>
        <div>3</div>
    </div>
    
</body>
</html>

在这里插入图片描述

  • grid-column-gap和grid-row-gap

定义网格中网格间隙的尺寸

.box2{width: 300px;height: 300px;border: 1px gray dotted;display: grid;
        grid-template: 
        "a1 a1 a1" 1fr
        "a2 a2 a3" 1fr
        "a2 a2 a3" 1fr
        /1fr 1fr 1fr;
        grid-column-gap: 10px;
        grid-row-gap:20px;
    }

在这里插入图片描述
CSS grid-gap属性是grid-column-gap和grid-row-gap属性的缩写

  • justity-items和align-items

注:place-items可以让justity-items和align-items属性写在单个声明中
在这里插入图片描述

.box3{width: 300px;height: 300px;border: 1px gray dotted;display: grid;
        grid-template-rows:repeat(3,1fr);
        grid-template-columns:repeat(3,1fr);
        justify-items: end;
        align-items: end;
    }
    .box3 div{background: palevioletred;border: 1px black solid;}

在这里插入图片描述

  • justity-content和align-content

在这里插入图片描述

5.作用在grid子项上的CSS属性

在这里插入图片描述

.box div{background: palevioletred;border: 1px black solid;
    grid-area: 3/2/4/4; /*第一个值是水平的起始位置,第二个值是垂直的起始位置,第三个值是水平的结束位置,第四个值是垂直的结束位置/
    }

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    .box{width: 280px;height: 352px;margin: 20px auto;display: grid;
    grid-template-columns: repeat(3,1fr);
    grid-template-rows: repeat(4,1fr);
    grid-template-areas:
    "a1 a2 a2"
    "a3 a2 a2"
    "a4 a4 a5"
    "a6 a7 a7";
    grid-gap:6px 6px;
    }
    .box div{background: red;}
    .box div:nth-child(1){grid-area: a1;}
    .box div:nth-child(2){grid-area: a2;}
    .box div:nth-child(3){grid-area: a3;}
    .box div:nth-child(4){grid-area: a4;}
    .box div:nth-child(5){grid-area: a5;}
    .box div:nth-child(6){grid-area: a6;}
    .box div:nth-child(7){grid-area: a7;}
    </style>
</head>
<body>
    <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
</html>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值