首页 > 代码库 > 第32 章项目实战-移动端流体布局4

第32 章项目实战-移动端流体布局4

第32 章项目实战-移动端流体布局[4]
学习要点:
1.旅游图片部分

本章主要开始如果通过第一个PC 端项目进行重构,设计成移动端可访问的页面,这个
项目采用的是流体布局。
一.旅游图片部分
//HTML 部分
<div class="container">
<figure>
<img src="http://www.mamicode.com/img/tour1.png" >
<figcaption>
<h4>&lt;曼谷-芭提雅6 日游&gt;</h4>
<p>包团特惠,超丰富景点</p>
<div class="info">
<em class="sat">满意度77%</em>
<span class="price">¥ <strong>2864</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour2.png" >
<figcaption>
<h4>&lt;马尔代夫双鱼岛Olhuveli4 晚6 日自助游&gt;</h4>
<p>上海出发,机+酒包含:早晚餐+快艇</p>
<div class="info">
<em class="sat">满意度97%</em>
<span class="price">¥ <strong>8039</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour3.png" >
<figcaption>
<h4>&lt;海南双飞5 日游&gt;</h4>
<p>含盐城接送,全程挂牌四星酒店</p>
<div class="info">
<em class="sat">满意度90%</em>
<span class="price">¥ <strong>2709</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour4.png" >
<figcaption>
<h4>&lt;富山-大阪-东京8 日游&gt;</h4>
<p>暑期亲子,2 天自由,无导游安排</p>
<div class="info">
<em class="sat">满意度97%</em>
<span class="price">¥ <strong>9499</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour5.png" >
<figcaption>
<h4>&lt;法瑞意德12 日游&gt;</h4>
<p>4 至5 星,金色列车,少女峰</p>
<div class="info">
<em class="sat">满意度97%</em>
<span class="price">¥ <strong>9199</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour6.png" >
<figcaption>
<h4>&lt;巴厘岛6 日半自助游&gt;</h4>
<p>蓝梦出海,独栋别墅,悦榕庄下午茶</p>
<div class="info">
<em class="sat">满意度95%</em>
<span class="price">¥ <strong>6488</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour7.png" >
<figcaption>
<h4>&lt;塞舌尔迪拜9 日自助游&gt;</h4>
<p>一游两国,4 晚塞舌尔,2 晚迪拜</p>
<div class="info">
<em class="sat">满意度100%</em>
<span class="price">¥ <strong>9669</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour8.png" >
<figcaption>
<h4>&lt;花样姐姐土耳其9 日或10 日游&gt;</h4>
<p>最高立减3000!中餐六菜一汤</p>
<div class="info">
<em class="sat">满意度93%</em>
<span class="price">¥ <strong>9999</strong> 起</span>
</div>
</figcaption>
</figure>
</div>
<div class="clearfix"></div>
//CSS 部分
//去掉边框计算
div,figure,figcaption {
box-sizing: border-box;
}
//样式部分
#tour figure {
width: 50%;
float: left;
background-color: #eee;
margin: 0 0 .05rem 0;
font-size: .16rem;
}
#tour figure img {
padding: .02rem;
vertical-align: middle;
border-radius: .04rem;
}
#tour figcaption {
color: #666;
padding: .02rem .05rem;
}
#tour figcaption h4 {
display: block;
font-weight: normal;
padding: .05px 0;
overflow: hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
#tour figcaption p {
overflow: hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
#tour .info {
padding: .1rem 0 0 0;
font-size: .16rem;
}
#tour .price {
color: #f60;
}
#tour .price strong {
letter-spacing: 0.01rem;
}
#tour .sat {
color: #999;
font-style: normal;
float: right;
position: relative;
right: .05rem;
}
//媒体查询
/*媒体查询,大于480px 小于640px*/
@media (min-width: 480px) and (max-width: 640px) {
#tour h2 {
font-size: .26rem;
}
#tour h3, #footer, #tour figure, #tour .info {
font-size: .16rem;
}
}
/*媒体查询,小于480px*/
@media (max-width: 480px) {
#tour h2 {
font-size: .20rem;
}
#tour h3, #tour .info,#tour figure {
font-size: .14rem;
}
#footer {
font-size: .12rem;
}
}

代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
<title>瓢城旅行社-移动端</title>
<link rel="stylesheet" href="http://www.mamicode.com/css/style.css">
</head>
<body>

<header id="header">
<nav class="link">
<h2 class="none">网站导航</h2>
<ul>
<li class="active"><a href="http://www.mamicode.com/index.html">首页</a></li>
<li><a href="http://www.mamicode.com/information.html">资讯</a></li>
<li><a href="http://www.mamicode.com/ticket.html">票务</a></li>
<li><a href="http://www.mamicode.com/about.html">关于</a></li>
</ul>
</nav>
</header>

<div id="adver">
<img src="http://www.mamicode.com/img/adver.png" >
</div>

<div id="search">
<input type="text" class="search" placeholder="请输入旅游景点或城市">
<button class="button">搜索</button>
</div>

<div id="tour">
<hgroup>
<h2>热门旅游</h2>
<h3>最新的各种热门旅游资讯的推荐!</h3>
</hgroup>
<div class="container">
<figure>
<img src="http://www.mamicode.com/img/tour1.png" >
<figcaption>
<h4>&lt;曼谷-芭提雅6 日游&gt;</h4>
<p>包团特惠,超丰富景点</p>
<div class="info">
<em class="sat">满意度 77%</em>
<span class="price">¥ <strong>2864</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour2.png" >
<figcaption>
<h4>&lt;马尔代夫双鱼岛Olhuveli4 晚6 日自助游&gt;</h4>
<p>上海出发,机+酒包含:早晚餐+快艇</p>
<div class="info">
<em class="sat">满意度 97%</em>
<span class="price">¥ <strong>8039</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour3.png" >
<figcaption>
<h4>&lt;海南双飞5 日游&gt;</h4>
<p>含盐城接送,全程挂牌四星酒店</p>
<div class="info">
<em class="sat">满意度90%</em>
<span class="price">¥ <strong>2709</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour4.png" >
<figcaption>
<h4>&lt;富山-大阪-东京8 日游&gt;</h4>
<p>暑期亲子,2 天自由,无导游安排</p>
<div class="info">
<em class="sat">满意度97%</em>
<span class="price">¥ <strong>9499</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour5.png" >
<figcaption>
<h4>&lt;法瑞意德12 日游&gt;</h4>
<p>4 至5 星,金色列车,少女峰</p>
<div class="info">
<em class="sat">满意度97%</em>
<span class="price">¥ <strong>9199</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour6.png" >
<figcaption>
<h4>&lt;巴厘岛6 日半自助游&gt;</h4>
<p>蓝梦出海,独栋别墅,悦榕庄下午茶</p>
<div class="info">
<em class="sat">满意度95%</em>
<span class="price">¥ <strong>6488</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour7.png" >
<figcaption>
<h4>&lt;塞舌尔迪拜9 日自助游&gt;</h4>
<p>一游两国,4 晚塞舌尔,2 晚迪拜</p>
<div class="info">
<em class="sat">满意度100%</em>
<span class="price">¥ <strong>9669</strong> 起</span>
</div>
</figcaption>
</figure>
<figure>
<img src="http://www.mamicode.com/img/tour8.png" >
<figcaption>
<h4>&lt;花样姐姐土耳其9 日或10 日游&gt;</h4>
<p>最高立减3000!中餐六菜一汤</p>
<div class="info">
<em class="sat">满意度93%</em>
<span class="price">¥ <strong>9999</strong> 起</span>
</div>
</figcaption>
</figure>
<div class="clearfix"></div>
</div>
</div>

<footer id="footer">
<div class="top">
客户端 | 触屏版 | 电脑版
</div>
<div class="bottom">
Copyright © YCKU 瓢城旅行社 | 苏ICP备120110119号
</div>
</footer>

</body>
</html>

 

@charset "utf-8";
html {
font-size: 625%;
}
body,h1,h2,h3,h4,p,ul,ol,form,fieldset,figure {
margin: 0;
padding: 0;
}
body {
background-color: #fff;
font-family: "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei UI", "Microsoft YaHei", SimHei, "\5B8B\4F53", simsun, sans-serif;
font-size: .16rem;
}
ul,ol {
list-style: outside none none;
}
a {
text-decoration: none;
}
img {
display: block;
max-width: 100%;
}
div,figure,figcaption {
box-sizing: border-box;
}
.none {
display: none;
}
.clearfix:after {
content: ‘.‘;
display: block;
clear: both;
height: 0;
visibility: hidden;
}
#header {
width: 100%;
height: .45rem;
background-color: #333;
font-size: 0.16rem;
}
#header .link {
height: .45rem;
line-height: .45rem;
color: #eee;
}
#header .link li {
width: 25%;
text-align: center;
float: left;
}
#header .link a {
color: #eee;
display: block;
}
#header .link a:hover,
#header .active a {
background-color: #000;
}
#adver {
max-width: 6.4rem;
margin: 0 auto;
}
#footer {
max-width: 6.4rem;
background-color: #222;
color: #777;
margin: 0 auto;
text-align: center;
padding: .1rem 0;
font-size: .16rem;
}
#footer .top {
padding: 0 0 .05rem 0;
}
#search {
max-width: 6.4rem;
height: .33rem;
margin: 0 auto;
background-color: #ddd;
padding: .03rem 0 0 0;
position: relative;
}
#search .search {
width: 95%;
height: .27rem;
border-radius: .04rem;
border: none;
outline: none;
background-color: #fff;
display: block;
margin: 0 auto;
font-size: .14rem;
padding: 0 .05rem;
}
#search .button {
display: block;
outline: none;
width: .5rem;
height: .27rem;
color: #666;
border: none;
background-color: #eee;
border-top-right-radius: .04rem;
border-bottom-right-radius: .04rem;
font-size: .14rem;
position: absolute;
top: .03rem;
right: 1%;
}
#tour {
max-width: 6.4rem;
margin: .1rem auto 0 auto;
}
#tour h2 {
text-align: center;
color: #666;
font-size: .26rem;
}
#tour h3 {
text-align: center;
color: #666;
font-weight: normal;
font-size: .16rem;
margin: .05rem 0 .1rem 0;
}
#tour figure {
width: 50%;
float: left;
background-color: #eee;
font-size: .16rem;
padding: 0 0 .05rem 0;
}
#tour figure img {
padding: .02rem;
border-radius: .04rem;
}
#tour figcaption {
color: #666;
font-size: .16rem;
padding: .02rem .05rem;
}
#tour h4 {
font-weight: normal;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tour p {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tour .info {
padding: .1rem 0 0 0;
font-size: .16rem;
}
#tour .price {
color: #f60;
}
#tour .price strong {
letter-spacing: .01rem;
}
#tour .sat {
position: relative;
float: right;
right: .05rem;
font-style: normal;
}


/*媒体查询,大于480px小于640px*/
@media (min-width: 480px) and (max-width: 640px) {
#tour h2 {
font-size: .26rem;
}
#tour h3, #footer, #tour figcaption, #tour .info {
font-size: .16rem;
}
}

/*媒体查询,小于480px*/
@media (max-width: 480px) {
#tour h2 {
font-size: .20rem;
}
#tour h3, #tour figcaption, #tour .info {
font-size: .14rem;
}
#footer {
font-size: .12rem;
}
}

第32 章项目实战-移动端流体布局4