最近接到领导的任务,要给外面的学生上几节前端课,备课的时候准备了一些小项目,在此记录一下。
以下是爱奇艺首页的一个导航栏,用原生js写的,静态页面效果如下:
代码如下:
爱奇艺 * { padding: 0; margin: 0; } .wrap { height: 520px; background-color: #000; width: 100%; } .wrap .img-wrap { height: 100%; margin: 0 auto; background-image: url('1.jpg'); background-repeat: no-repeat; background-position: 50% 50%; background-size: auto 100%; position: relative; } @media screen and (max-width: 2000px) { .wrap .img-wrap .item-list { right: 10%; } } @media screen and (max-width: 1600px) { .wrap .img-wrap .item-list { right: 8%; } } @media screen and (max-width: 1300px) { .wrap .img-wrap .item-list { right: 5%; } } .wrap .img-wrap .item-list { box-sizing: border-box; height: 100%; background-color: rgba(0,0,0,0.7); width: 280px; position: absolute; list-style: none; padding: 10px 0; } .wrap .img-wrap .item-list li { padding: 0 15px; } .wrap .img-wrap .item-list li.active { background: linear-gradient(to right, rgba(0,0,0,.5), rgba(0,0,0,0)); cursor: pointer; } .wrap .img-wrap .item-list li span { line-height: 40px; color: #eee; font-size: 16px; } .wrap .img-wrap .item-list li.active span { color: #00be06; display: block; } .wrap .img-wrap .item-list li.active span:nth-child(1) { font-size: 24px; transition: font-size 0.2s; } .wrap .img-wrap .item-list li.active span:nth-child(2) { display: none; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



