轮播图
- 用动画来做 ```html <!DOCTYPE html>
<a name="FJpLg"></a># 万能导航栏1. 适用于需要长/短边框做分割线情境下1. 给`<li>`设置左浮,给`<a>`设置`padding`- 想要短的边框给`<a>`设置- 想要长的边框给`<li>`设置```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>万能导航栏</title><style>* {margin: 0;padding: 0;}nav {width: 1200px;height: 100px;line-height: 100px; /* 设置行高等于高度 */margin: 0 auto;background: cyan;}/* 1、去除列表样式 去除超链接下划线*/ul,li {list-style: none;}a {/* 3、给a设置左右padding */padding: 0 30px;border-right: 2px solid #FFF; /* 给a设置右边框 *//* background: red; */text-decoration: none;}/* 2、给li设置浮动 */nav li {float: left;/* border-right: 2px solid #000; 给li设置右边框 *//* background: springgreen; */}/** 4、你需要和高度一致的边框 那就给li设置边框* 你需要和文字一样的边框 那你就a设置边框* 注意!a不能设置浮动*/</style></head><body><nav><!-- 0、万能导航栏 建议ul>li>a --><ul><li><a href="javascript:;">全部商品</a></li><li><a href="javascript:;">全部商品</a></li><li><a href="javascript:;">全商品</a></li><li><a href="javascript:;">商品</a></li><li><a href="javascript:;">全部啊商品</a></li><li><a href="javascript:;">全部商品</a></li><li><a href="javascript:;">全部商品</a></li><li><a href="javascript:;">全部商品</a></li></ul></nav></body></html>
- 给a设置右边框效果图

- 给li设置右边框效果图
考拉
导航栏
<!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>
* {
margin: 0;
padding: 0;
}
p {
overflow: hidden;
width: 300px;
height: 80px;
border: 1px solid #f00;
margin: 100px 0 0 100px;
background: pink;
border-radius: 40px;
}
input {
float: left;
outline: 0;
width: 200px;
height: 80px;
border: 0;
background: pink;
/* 设置圆角 左上 右上 右下 左下 */
border-radius: 40px 0 0 40px;
}
button {
float: left;
width: 100px;
height: 80px;
border: 0;
background: #ff0;
border-radius: 40px 0 0 40px;
}
</style>
</head>
<body>
<p>
<input type="text"><button></button>
</p>
</body>
</html>
完整页面
QQ截图20220113173840.png考拉海购.png
<!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="stylesheet" href="../iconfont.css">
<!-- 引入外部样式表 -->
<link rel="stylesheet" href="../css/kaola.css">
</head>
<body>
<!-- 头部 因为外围有颜色 所以需要写外围+版心-->
<div id="headerWrapper">
<header class="same">
<!-- 头部左侧 -->
<div class="headLeft">
<a href="javascript:;">考拉欢迎你</a>
<a href="javascript:;">登录</a>
<a href="javascript:;">免费注册</a>
<a href="javascript:;">手机考拉</a>
</div>
<!-- 头部右侧 -->
<ul class="headRight">
<li><a href="javascript:;">每日签到</a></li>
<li><a href="javascript:;">我的订单</a></li>
<li class="yiji"><a href="javascript:;">个人中心<img src="../images/1.png" alt=""></a></li>
<li class="yiji"><a href="javascript:;">客户服务<img src="../images/1.png" alt=""></a></li>
<li class="yiji"><a href="javascript:;">充值中心<img src="../images/1.png" alt=""></a></li>
<li class="yiji">
<a href="javascript:;">消费者权益<img src="../images/1.png" alt=""></a>
<!-- 在这里写二级 和<a>兄弟同级 因为鼠标滑过通栏时出现下拉菜单 也就是滑过整块li时 -->
<div class="erji">
<a href="javascript:;">消费者告知书</a>
</div>
</li>
<li class="yiji"><a href="javascript:;">更多<img src="../images/1.png" alt=""></a></li>
<li><a href="javascript:;">视频内容</a></li>
</ul>
</header>
</div>
<!-- 导航栏 外围没有颜色 直接写版心 -->
<nav class="same">
<img src="../images/3.png" alt="">
<p>
<input type="text">
<button></button>
</p>
<input type="button" value="购物车">
</nav>
<!-- 一级 所有分类部分 -->
<article class="same">
<section>
<i class="iconfont icon-toggle"></i>
所有分类
<!-- 二级写在一级里面 注意!只有学习CSS阶段这么写 -->
<ul>
<li>
<i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i>
<div class="sanji" style="background: olive;"></div>
</li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li>
<i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i>
<div class="sanji" style="background: tomato;"></div><!-- 注意!三级别写在i里面 -->
</li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li>
<i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i>
<div class="sanji" style="background: springgreen;"></div>
</li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i></li>
<li class="noborder"><i class="iconfont icon-kouhong"></i>美容彩妆 <i class="iconfont icon-arrow-right"></i>
</li>
</ul>
</section>
<section>首页</section>
<section>海外直购</section>
<section>考拉海购出品</section>
<section>品质奶粉</section>
<section>人气面膜</section>
<section>充值</section>
</article>
<!-- 大图区域 -->
<div id="banner">
<img src="../images/1.jpg" alt="">
<div class="end">
<hgroup class="same"></hgroup>
</div>
</div>
</body>
</html>
/* 去除页面缝隙 */
* {
margin: 0;
padding: 0;
}
/* 去除页面所有超链接下划线 重置超链接颜色*/
a {
text-decoration: none;
color: #999999;
}
/* 文字大小具有继承性 所以我先给body设置文字大小 */
body {
font-size: 12px;
}
/* 去除页面所有列表样式 */
ol,
li,
ul {
list-style: none;
}
/* -----------统筹----- */
/* 因为页面版心都是一样的宽度1095 都需要水平居中 所以我给这几块大的版心起了一个相同的class名字same */
.same {
width: 1095px;
margin: 0 auto;
}
/* -----------头部------ */
#headerWrapper { /* 外围只需要设置背景色 */
/* 因为边框是延展到外围 所以设置给外围 */
border-bottom: 1px solid #ededee;
background: #000;
}
header {
height: 30px;
line-height: 30px; /* 单行文本垂直居中 */
/* background: pink; */
}
header a {
padding: 0 18px;
/* background: cyan; */
}
header a:hover {
color: #FFF;
}
.headLeft {
float: left;
}
.headLeft>a:first-of-type {
padding: 0 12px 0 0;
}
.headRight {
float: right;
}
.headRight li a>img {
vertical-align: middle;
}
.headRight li {
float: left;
position: relative;
}
.yiji a:hover {
color: #ff1e32;
}
/* -------二级---- */
/*
* 二级永远绝对定位
* 二级我希望根据父元素li进行定位 li有一个class叫yiji 父相子绝即可
* 因为是根据“消费者权益”这一整个小板块进行定位的
*/
.erji {
/* 默认二级是不在的 */
display: none;
position: absolute;
left: 0;
top: 30px;
width: 100%;
height: 44px;
background: #FFF;
}
.erji a {
padding-right: 0;
}
/* 什么情况下二级在 鼠标滑过li 二级出现 */
.headRight li:hover .erji {
display: block;
}
.yiji:hover {
background: #fff;
}
/* 导航栏部分 */
nav {
height: 100px;
/* background: pink; */
}
nav>img {
float: left;
margin-top: 26px;
/* logo距离上方26px */
}
nav p * { /* 代表nav里面p里面所有元素 */
float: left;
width: 448px;
height: 36px;
/* 它俩都需要去除边框 */
border: 0;
outline: 0;
}
nav p button {
width: 60px;
background: #ff2c61 url(../images/5.png) no-repeat center;
border-radius: 18px; /* 设置圆角 高度一半36/2=18 */
}
nav p {
float: left;
/* 为啥 因为p是块状元素 独占一行 我想图片 p 购物车按钮在一行 所以浮动 */
overflow: hidden;
border: 2px solid #ff2337;
margin: 33px 0 0 147px;
background: #ff2c61;
border-radius: 20px; /* 36+4=40 */
}
input[type="button"] { /* 写法参考day11-CSS3选择器及属性 */
float: left;
width: 110px;
height: 40px;
border: 2px solid #ff2337;
margin: 33px 0 0 50px; /* button参考day7-小米搜索框 button属性委屈自己 */
background: #FFF url(../images/4.png) no-repeat 20px center;
color: #333333;
text-indent: 39px; /* 调整按钮中“购物车”文字的位置 */
border-radius: 20px;
}
/* ---------所有分类部分----- */
article {
height: 43px;
line-height: 40px;
}
section {
float: left;
padding: 0 20px;
font-size: 14px;
font-weight: bold;
color: #333333;
}
section:first-of-type {
/* 父相子绝 */
position: relative;
width: 164px;
padding: 0;
margin-right: 25px;
color: #FFF;
background: linear-gradient(to right, #ff0103, #ff3162);
font-weight: normal;
}
article .iconfont { /* 儿子 孙子级别全部被选中 */
color: #dddddd;
}
section>.iconfont { /* 儿子级别的被选中 */
margin: 0 24px 0 15px;
}
/* 注意!!注意!!你上方 代表选中了article里面所有矢量图 不行啊 */
section li .iconfont:first-of-type { /* 选中了section里面li 里面的第一个i */
margin: 0 27px 0 16px;
}
section li .iconfont:last-of-type {
float: right;
margin-right: 16px;
}
/* 这个是在轮播图的区域 */
section ul {
/* 设置定位 设置绝对定位 */
position: absolute;
left: 0;
top: 41px; /* 行高40边框1 */
z-index: 3; /* 将导航栏置顶于banner大图上面 */
width: 154px; /* 164-10=154 */
height: 460px;
line-height: 37px;
padding: 0 7px 0 3px;
background: linear-gradient(to right, #ff0103, #ff3162);
}
section ul li {
border-bottom: 1px solid #ff5160;
}
.noborder {
border: 0 !important;
}
/* 我们开始写三级啦 */
.sanji {
/* 默认三级消失 */
display: none;
/* 三级也是定位 绝对定位 */
position: absolute;
left: 164px;
top: 0;
width: 928px;
height: 460px;
}
/* 鼠标滑过二级里面的li 对应的三级出现 */
section ul li:hover .sanji { /* 写法参考day2-CSS样式表的创建及其优先级 */
display: block;
}
/* -----------------bannner----------- */
#banner {
position: relative;
overflow: hidden;
height: 506px;
}
#banner img {
position: absolute;
left: 50%;
top: 0;
transform: translateX(-50%);
}
#banner .end {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 44px;
background: rgba(0, 0, 0, 0.5);
}
.hgroup {
height: 44px;
background: cyan;
}
万表网
头部二级边框问题




<!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>
* {
margin: 0;
padding: 0;
}
header {
width: 1200px;
height: 100px;
line-height: 100px;
margin: 0 auto;
background: pink;
}
/* 头部导航栏 居右---右浮 */
.headRight {
float: right;
list-style: none;
}
/* 万能导航栏 给li设置左浮 给a设置左右padding 想要短的边框给a设置 想要长的边框给li设置 */
.headRight>li {
position: relative;
float: left;
height: 97px; /* 100-2border-1margin-top=97 */
border: 1px solid transparent; /* 因为border自带边框 加入透明色边框后 鼠标滑过li不会颤抖 transparent透明边框 */
margin-top: 1px; /* 因为原图顶部有1px间隙 对照辅助参考图1 */
background: springgreen;
}
.headRight>li>a {
border-right: 1px solid #fff;
padding: 0 30px;
background: pink;
color: #333;
text-decoration: none;
}
/*
* 注意 li在默认情况下就应该存在边框 只不过颜色看不见而已(透明色) 参考第34行代码
* 鼠标滑过倒数第三个li 让li边框颜色改变
*/
.headRight li:nth-last-of-type(3):hover {
border-color: #f00; /* 如果li不设置边框 鼠标滑过时候会抖 */
background: #FFF;
}
/* -------二级----- */
.erji {
/* 默认消失 */
display: none;
/* 二级永远绝对定位 参考day8-定位position */
position: absolute;
/* right区域是根据padding区域 来定位的 对照辅助参考图3 */
right: -1px;
/*
* 根据父元素.headRight>li的border区域来下沉定位97+2=99 参考day8-定位position
* 也就是说 top值=li高度97+上下border2-往上移动1px=98 对照辅助参考图2
*/
top: 98px;
width: 300px;
height: 400px;
background: rgb(150, 144, 144);
border: 1px solid #f00;
}
/* 鼠标滑过 出现 */
li:hover .erji {
/* 参考day11-CSS3选择器及属性 */
display: block;
}
/* 注意 去除一小部分的边框 我们需要使用伪类来盖住 */
.headRight li:nth-last-of-type(3)::after {
position: absolute;
/* 根据父元素.headRight>li来定位 */
left: 0;
bottom: -2px;
content: "";
width: 100%;/* 注意 100%是谁的 父元素的吗 不是 根据谁定位 就是谁的 */
height: 2px;
background: #f90; /* 正常情况写成白色来盖住 此处写颜色便于查找 */
}
</style>
</head>
<body>
<header>
<!-- ul>li>a和div -->
<ul class="headRight">
<li><a href="javascript:;">首页1</a></li>
<li><a href="javascript:;">首页2</a></li>
<li><a href="javascript:;">首页3</a></li>
<li>
<a href="javascript:;">首页4</a>
<div class="erji">在这里加二级</div>
</li>
<li><a href="javascript:;">首页5</a></li>
<li><a href="javascript:;">首页6</a></li>
</ul>
</header>
</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>
* {
margin: 0;
padding: 0;
}
nav {
width: 1200px;
height: 100px;
line-height: 100px;
margin: 0 auto;
/* background: pink; */
}
section {
position: relative;
float: left;
margin: 0 30px; /* 因为文字下边的边框和文字齐宽,所以不用padding */
/* background: skyblue; */
}
/* 我们先加上 伪类 模拟的边框 */
section:hover::after {
position: absolute;
left: 0;
bottom: 5px;
content: "";
width: 100%; /* 代表宽度和包含块的宽度一样 */
/* 什么是包含块 你根据谁定位 谁就是包含块 */
height: 1px;
background: tomato;
}
</style>
</head>
<body>
<nav>
<section>男表</section>
<section>女表</section>
<section>秒杀</section>
<section>手表行情</section>
<section>品牌馆</section>
<section>体验中心</section>
<section>名匠维修</section>
</nav>
</body>
</html>
<!-- section::after表示section各个状态下都有这个伪类
section:hover::after表示section滑过状态下有这个伪类 -->
鼠标滑过图片放大

<!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>
.big {
position: relative;
overflow: hidden;
width: 400px;
height: 400px;
}
.big>img {
width: 400px;
height: 400px;
border: 0;
vertical-align: top; /* 解决图片三像素问题 也可以用display: block; */
transition: 1s; /* 谁变化给谁加1s */
}
/* 注意 鼠标滑过big 图变大了 */
.big:hover img {
transform: scale(1.5);
}
article {
position: absolute;
top: 10px;
width: 100%; /* 让文本水平居中 如果隐藏这行代码高度则由内容撑开 */
/* background: pink; */
text-align: center; /* 文字水平居中 */
}
</style>
</head>
<body>
<div class="big">
<img src="https://image8.wbiao.co/mall/806af5bef42f421a84871cfb683796f8.jpg?x-oss-process=image/resize,w_291"
alt="">
<article>
<b>是加粗的那一拨文字</b>
<p>这样子就是两行,因为p是块状元素,不会和行内b 在一行显示</p>
<!-- <p>哈哈哈</p> -->
<!-- 段落标签<P>不可以嵌套包裹其他块状元素 -->
</article>
</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 {
width: 1000px;
height: auto;
overflow: hidden;
background: #ddd;
margin: 0 auto;
}
section {
width: 400px;
height: 300px;
background: #fff;
float: left;
margin-right: 100px;
margin-bottom: 30px;
border: 3px solid #000;
transition: 0.5s;
}
section:nth-of-type(2n) {
margin-right: 0;
}
section:hover {
/* 盒子阴影 */
box-shadow: 0px 0px 20px 3px #000;
/* 盒子向上移动 参考day12-2D、3D */
transform: translateY(-5px);
}
</style>
</head>
<body>
<main>
<!-- 也可以用div替换section -->
<section></section>
<section></section>
<section></section>
<section></section>
<section></section>
<section></section>
<section></section>
</main>
</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>
.big {
position: relative;
overflow: hidden;
width: 500px;
height: 400px;
margin: 100px auto;
}
.big>img {
width: 500px;
height: 400px;
}
article {
position: absolute;
left: 0;
bottom: -100px;
width: 100%;
height: 100px;
background: rgba(255, 255, 255, 0.5);
text-align: center;
transition: 1s;
}
/* 鼠标滑过div 让article的bottom值变为0 从-100变成0 就u看见了 */
.big:hover article {
bottom: 0;
}
</style>
</head>
<body>
<div class="big">
<img src="https://image8.wbiao.co/mall/806af5bef42f421a84871cfb683796f8.jpg?x-oss-process=image/resize,w_291"
alt="">
<article>
<p>里面很多文字啊</p>
<b>就是第二行 因为p独占一行</b>
</article>
</div>
</body>
</html>
虚焦
鼠标滑过图片后虚焦
.class名:hover>img {
filter: blur(2px);
}
<!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>
img:hover {
filter: blur(2px); /* 虚焦 */
}
</style>
</head>
<body>
<img src="1.jpg" alt="">
</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>
.big {
position: relative;
width: 600px;
height: 400px;
}
.big>img {
display: block; /* 解决图片3px问题 */
width: 600px;
height: 400px;
border: 0;
}
/* 鼠标滑过big 里面的子元素img 虚焦 */
.big:hover>img {
filter: blur(2px);
}
.imgList {
/* 默认不出 */
display: none;
position: absolute;
left: 50%;
top: 50%;
/* margin-left: 负宽度一半; */
/* margin-top: 负高度一半; */
transform: translate(-50%, -50%);
width: 300px;
height: 200px;
background: pink;
}
/* 鼠标滑过big imgList出现 */
.big:hover .imgList {
display: block; /* display是没有transition过渡时间的 不用给它加 无效 */
}
</style>
</head>
<body>
<div class="big">
<img src="1.jpg"
alt="">
<div class="imgList"></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>
.small{
width: 500px;
height: 300px;
position: relative;
}
.small img{
width: 500px;
height: 300px;
position: absolute;
left: 0;
top: 0;
}
.small section{
display: none;
position: absolute;
left: 0;
top: 0;
width: 500px;
height: 300px;
background: skyblue;
}
/* 你呢 先让section消失 鼠标滑过再出现就对了 */
.small:hover section{
display: block;
}
</style>
</head>
<body>
<div class="small">
<img src="https://image8.wbiao.co/mall/806af5bef42f421a84871cfb683796f8.jpg?x-oss-process=image/resize,w_291" alt="">
<section>你想切换时是文字形式就用section标签 否则也是img标签</section>
</div>
</body>
</html>

