课程作业:
- 制作一个在线QQ客服的固定定位(QQ客服用图片就行);
- 仿课堂案例写一个三行三列的定位布局, 色块或边框代表内容就可以;
- 将之前落下的作业补齐;
- 在mdn上预习flex和js的知识,下周要学习.
作业内容:
1、制作一个在线QQ客服的固定定位
知识点:
1、引用iconfont图标制作客服窗口
2、使用position:fixed;
固定定位在线客服窗口位置在右边
实例代码:
<!DOCTYPE html>
<html lang="zh-CN">
<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>在线QQ客服固定定位</title>
<link
rel="stylesheet"
href="//at.alicdn.com/t/font_2650193_58a6zhtdo67.css"
/>
<style>
html {
background-color: bisque;
min-height: 1500px;
}
.kefu {
width: 7em;
border: 1px solid;
padding: 20px;
margin: 20px;
text-align: center;
background-color: #3860f4;
position: fixed;
top: 30vh;
right: 0;
}
.icon-kefu {
color: #ffffff;
font-size: 6em;
}
.kefu-01 {
color: #ffffff;
}
</style>
</head>
<body>
<h1>在线客服联系固定窗口</h1>
<div class="kefu">
<a class="kefu-01">在线客服联系</a>
<br />
<div class="kefu-img"><i class="iconfont icon-kefu"></i></div>
<div class="kefu-lianxi">
<button>点击我联系客服</button>
</div>
</div>
</body>
</html>
最终效果:
2、仿课堂案例写一个三行三列的定位布局, 色块或边框代表内容就可以;
实例代码:
<!DOCTYPE html>
<html lang="zh-CN">
<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>三行三列实例</title>
<link
rel="stylesheet"
href="//at.alicdn.com/t/font_2650193_58a6zhtdo67.css"
/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* body *:not(.container) {
background-color: lightgreen;
} */
:root {
font-size: 10px;
}
body {
font-size: 1.6rem;
}
header,
footer {
height: 10rem;
text-align: center;
background-color: lightskyblue;
min-width: inherit;
}
.container {
margin: 0.5rem 0;
position: relative;
/* min-height: 600px; */
min-height: calc(100vh - 21rem);
}
.container aside {
width: 20rem;
background-color: yellow;
min-height: inherit;
position: absolute;
/* text-align: center; */
/* 绝对定位必须要有一个定位父级元素(定位元素) */
position: absolute;
}
/* 右侧定位 */
.container aside:last-of-type {
right: 0;
top: 0;
}
.container main {
position: absolute;
left: 20.5rem;
right: 20.5rem;
background-color: lightcoral;
min-height: inherit;
}
img {
position: relative;
width: 100%;
height: 100%;
}
nav {
display: inline;
}
footer div {
line-height: 10rem;
}
.kefu {
/* width: 9em; */
border: 1px solid;
padding: 5px;
margin: 15px;
text-align: center;
background-color: #3860f4;
}
.icon-kefu {
color: #ffffff;
font-size: 6em;
}
.kefu-01 {
color: #ffffff;
}
</style>
</head>
<body>
<header>
<img src="./img/banner.jpg" alt="" />
</header>
<div class="container">
<aside>左边</aside>
<main>中间</main>
<aside>
<div class="kefu">
<a class="kefu-01">在线客服联系</a>
<br />
<div class="kefu-img"><i class="iconfont icon-kefu"></i></div>
<div class="kefu-lianxi">
<button>点击我联系客服</button>
</div>
</div>
</aside>
</div>
<footer>
<div>
友情链接:
<nav class="nav-1"><a href="http://www.php.cn">PHP中文网</a></nav>
<nav class="nav-2">
<a href="http://www.haofanghui.net">好房会网站</a>
</nav>
</div>
</footer>
</body>
</html>