移动web)开发(4)之携程案例
又到了做案例巩固的时候了,下面放一些制作的大纲,提供思路.这一期比较水了.
唉,光是最上面的搜索框就一大堆代码,有点麻烦,而且很多东西想不到,真的是哭了呜呜呜...
背景渐变必须添加私有前缀.如果不指定方向的话默认是从上往下渐变的.
效果:
如果想要沿着对角线渐变的话,就将方向改成 top left. 这是左上到左下的渐变,其他的方向也是可以的.
断断续续看了两天终于看完这个案例,自己也跟着敲了一遍,虽然说flex很牛逼但是还是好麻烦啊啊啊,心力交瘁啊,在做的过程中多次被震撼,怎么还能做这么做???
代码:
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, user-scalable=no,minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="./css/normalize.css">
<link rel="stylesheet" href="./css/index.css">
<title> 携程在手,说走就走</title>
</head>
<body>
<!-- 顶部搜索模块 -->
<div class="search-index">
<div class="search">
<!-- 因为前面有个块级元素,所以文字会被挤下来!!! -->
搜索:目的地/酒店/景点/航班号
</div>
<a href="#" class="user">我 的</a>
</div>
<!-- 焦点图模块 -->
<div class="focus">
<img src="./upload/focus.jpg" alt="">
</div>
<!-- 局部导航栏 -->
<ul class="local-nav">
<li><a href="#" title="景点·玩乐">
<span class="local-nav-icon"></span>
<span>景点·玩乐</span>
</a></li>
<li><a href="#">
<span class="local-nav-icon"></span>
<span>景点·玩乐</span>
</a></li>
<li><a href="#">
<span class="local-nav-icon"></span>
<span>景点·玩乐</span>
</a></li>
<li><a href="#">
<span class="local-nav-icon"></span>
<span>景点·玩乐</span>
</a></li>
<li><a href="#">
<span class="local-nav-icon"></span>
<span>景点·玩乐</span>
</a></li>
</ul>
<nav>
<div class="nav-common">
<div class="nav-items">
<a href="#">海外酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
</div>
<div class="nav-common">
<div class="nav-items">
<a href="#">海外酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
</div>
<div class="nav-common">
<div class="nav-items">
<a href="#">海外酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
</div>
</nav>
<!-- 侧导航栏 -->
<ul class="subnav">
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<span class="subnav-icon"></span>
<span>电话费</span>
</a>
</li>
</ul>
<!-- 销售模块 -->
<div class="sales">
<div class="sales-hd">
<h2>热门活动</h2>
<a href="#" class="more">获取更多福利</a>
</div>
<div class="sales-bd">
<div class="row">
<a href=""><img src="./upload/pic1.jpg" alt=""></a>
<a href=""><img src="./upload/pic2.jpg" alt=""></a>
</div>
<div class="row">
<a href=""><img src="./upload/pic3.jpg" alt=""></a>
<a href=""><img src="./upload/pic4.jpg" alt=""></a>
</div>
<div class="row">
<a href=""><img src="./upload/pic5.jpg" alt=""></a>
<a href=""><img src="./upload/pic6.jpg" alt=""></a>
</div>
</div>
</div>
</body>
</html>
CSS部分:
body {
540px; :
320px; :
margin: 0 auto;
font: normal 14px/1.5 tahoma,"Lucida Grande",Verdana,"microsoft Yahei", STXihei,hei;
color: #000;
background: #f2f2f2;
隐藏水平滚动条 */
hidden; :
transparent; :
height: 2000px; */
}
div {
border-box; :
}
a {
none; :
color: #222;
}
a img {
none; :
}
li {
none; :
}
ul {
padding: 0;
margin: 0;
}
顶部搜索模块 */
{
固定定位不以父元素为准而以屏幕为准,所以要给它一个宽度的范围限制 */
320px; :
540px; :
display: flex;
position: fixed;
top: 0;
left: 50%;
由于宽度是会变化的,所以不能使用margin-left */
transform: translateX(-50%);
兼容老版本的浏览器 */
translateX(-50%); :
固定的盒子必须要有宽度 */
width: 100%;
height: 44px;
#f6f6f6; :
1px solid #ccc; :
1px solid #ccc; :
}
{
position: relative;
flex: 1;
height: 26px;
24px; :
border: 1px solid #ccc;
margin: 7px 10px;
25px; :
5px; :
color: #666;
0 2px 4px rgba(0,0,0,.2); :
}
:before { :
position: absolute;
content: '';
left: 5px;
top: 5px;
display: block;
width: 16px;
height: 15px;
background: url(../images/sprite.png) no-repeat -58px -279px;
104px 328px; :
}
{
这是整个user部分的大小 */
width: 44px;
height: 44px;
12px; :
center; :
}
:before { :
content: '';
display: block;
图片的大小为24*26 */
width: 24px;
height: 26px;
background: url(../images/sprite.png) -58px -193px no-repeat;
104px 328px; :
margin: 2px auto -2px;
}
{
44px; :
}
img {
width: 100%;
}
{
display: flex;
height: 64px;
#fff; :
8px; :
margin: 3px 4px;
}
li {
flex: 1;
height: 64px;
background-color: blueviolet; */
}
li a {
display: flex;
column; :
因为没有给a高度,所以是不能在y轴上居中的. */
center; :
12px; :
}
{
width: 32px;
height: 32px;
background: url(../images/localnav_bg.png) 0 0 no-repeat;
8px; :
32px 160px; :
}
nav {
overflow: hidden;
margin: 0 4px 3px;
8px; :
}
{
display: flex;
height: 88px;
pink; :
}
nth-child(2) { :
3px; :
3px; :
}
.nav-items {
display: flex;
column; :
flex: 1;
44px; :
center; :
justify-content: center; */
center; */ :
}
nth-child(-n+2) { :
1px solid #fff; :
}
a {
flex: 1;
color: #fff;
14px; :
1px 1px rgba(0,0,0,.2); :
}
a:nth-child(1) {
1px solid #fff; :
}
nth-child(1) a { :
none; :
background: url(../images/hotel.png) bottom center no-repeat;
121px auto; :
}
{
background: -webkit-linear-gradient(left,#fa5a55,#fa994d);
}
.subnav {
display: flex;
wrap; :
padding: 5px 0;
8px; :
#fff; :
margin: 0 4px;
}
li {
flex: 20%;
}
a {
display: flex;
column; :
justify-content: center; */
center; :
}
{
width: 28px;
height: 28px;
4px; :
pink; :
background: url(../images/subnav-bg.png);
28px auto; :
}
{
#fff; :
4px; ; :
}
{
position: relative;
1px solid #bbb; :
height: 44px;
1px solid #ccc; :
}
h2 {
position: relative;
0px; :
}
h2::after {
使用了绝对定位所以不用转换成块级元素 */
position: absolute;
top: 12px;
left: 20px;
display: block; */
content: '';
width: 79px;
height: 20px;
background: url(../images/hot.png) 0 -18px;
79px auto; :
}
{
position: absolute;
top: 8px;
right: 5px;
background: -webkit-linear-gradient(left, #ff506c, #ff6bc6);
15px; :
padding: 3px 20px 3px 10px;
color: #fff;
}
:after { :
content: '';
position: absolute;
top: 9px;
right: 9px;
width: 5px;
height: 5px;
2px solid #fff; :
2px solid #fff; :
rotate(45deg); :
}
{
display: flex;
1px solid #eee; :
}
a {
flex: 50%;
}
a img {
width: 100%;
}
a:nth-child(odd) {
1px solid #eee; :
}