第33章项目实战-兼容式响应布局2

author author     2022-08-05     295

关键词:

第33 章项目实战-兼容响应式布局[2]
学习要点:
1.搜索响应式
2.底部响应式

本章主要开始如果将前两个项目再进行重构,设计成既可以在PC 端正常显示,又可以
在PAD 上浏览,还可以在移动端有良好的体验。这些都必须兼容,那只有使用响应式设计
了。
一.搜索响应式
在PC 端,我们将搜索的文本框和按钮至于大背景前,移动端我们直接放在了大图片的
下方。那么在响应式这里,我们还是遵循PC 端,只不过采用流体缩放外加响应式控制来兼
容显示。
//PC 端移植,并稍作修改
<div id="adver">
<img src="img/adver.jpg" >
<div class="center"></div>
<div class="center copy">
<input type="text" class="search" placeholder="请输入旅游景点或
城市">
<button class="button">搜索</button>
</div>
</div>
//CSS 部分,基本是PC 端移植,并改为流体百分比
#adver {
max-width: 1920px;
margin: 0 auto;
padding: 70px 0 0 0;
position: relative;
}
#adver .center {
width: 40%;
height: 60px;
background-color: #000;
position: absolute;
top: 50%;
left: 50%;
margin: -10px 0 0 -20%;
opacity: 0.6;
border-radius: 10px;
}
#adver .copy {
opacity: 1;
background-color: transparent;
padding: 3px 3px 0 3px;
}
#adver .search {
width: 70%;
height: 52px;
background-color: #eee;
color: #666;
border: 1px solid #666;
border-radius: 10px;
font-size: 24px;
padding: 0 10px;
outline: none;
display: block;
float: left;
}
#adver .button {
width: 30%;
height: 54px;
background-color: #eee;
color: #666;
border: 1px solid #333;
border-left-width: 3px;
border-radius: 10px;
font-size: 24px;
outline: none;
cursor: pointer;
font-weight: bold;
display: block;
float: right;
}
//媒体查询部分
/*在992 和1199 像素之间的屏幕里,这里的样式才生效*/
@media (min-width: 992px) and (max-width: 1199px) {
#adver .center {
width: 50%;
margin: -10px 0 0 -25%;
}
}
/*在768 和991 像素之间的屏幕里,这里的样式才生效*/
@media (min-width: 768px) and (max-width: 991px) {
#adver .center {
width: 60%;
margin: -10px 0 0 -30%;
}
}
/*在480 和767 像素之间的屏幕里,这里的样式才生效*/
@media (min-width: 480px) and (max-width: 767px) {
#header, #header .center, #header .logo, #header .link {
height: 45px;
}
#header .link {
line-height: 45px;
}
#header .logo, .sm-hidden {
display: none;
}
#header .link {
width: 100%;
}
#adver {
padding: 45px 0 0 0;
}
#adver .center {
width: 70%;
margin: -10px 0 0 -35%;
}
#adver .search {
height: 45px;
font-size: 18px;
}
#adver .button {
height: 45px;
font-size: 18px;
}
#adver .center {
height: 53px;
}
.sm-visible {
display: block;
}
#footer .bottom {
height: 40px;
line-height: 40px;
}
}
/*在小于480 像素的屏幕,这里的样式才生效*/
@media (max-width: 479px) {
#header, #header .center, #header .logo, #header .link {
height: 45px;
}
#header .link {
line-height: 45px;
}
#header .logo, .xs-hidden, .sm-hidden {
display: none;
}
#header .link {
width: 100%;
}
#header .link li {
width: 25%;
}
#adver {
padding: 45px 0 0 0;
}
#adver .center {
width: 80%;
margin: -10px 0 0 -40%;
}
#adver .search {
height: 40px;
font-size: 16px;
}
#adver .button {
height: 40px;
font-size: 16px;
}
#adver .center {
height: 48px;
}
.sm-visible {
display: block;
}
#footer .bottom {
height: 40px;
line-height: 40px;
font-size: 13px;
}
}
二.底部响应式
底部的响应式很好理解,就是大屏幕采用PC 端,小屏幕采用移动端,进行响应式隐藏
即可。
//PC 端复制过来,进行部分修改
<footer id="footer">
<div class="top sm-hidden">
<div class="block left">
<h2>合作伙伴</h2>
<hr>
<ul>
<li>途牛旅游网</li>
<li>驴妈妈旅游网</li>
<li>携程旅游</li>
<li>中国青年旅行社</li>
</ul>
</div>
<div class="block center">
<h2>旅游FAQ</h2>
<hr>
<ul>
<li>旅游合同签订方式?</li>
<li>儿童价是基于什么制定的?</li>
<li>旅游的线路品质怎么界定的?</li>
<li>单房差是什么?</li>
<li>旅游保险有那些种类?</li>
</ul>
</div>
<div class="block right">
<h2>联系方式</h2>
<hr>
<ul>
<li>微博:weibo.com/ycku</li>
<li>邮件:[email protected]</li>
<li>地址:江苏盐城无名路123 号</li>
</ul>
</div>
</div>
<div class="clearfix"></div>
<div class="version sm-visible">
客户端| 触屏版| 电脑版
</div>
<div class="bottom">
Copyright © YCKU 瓢城旅行社| 苏ICP 备120110119 号<span
class="sm-hidden">| 旅行社经营许可证:L-YC-BK12345</span>
</div>
</footer>

 

代码:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>瓢城旅行社--响应式</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>

<header id="header">
<div class="center">
<h1 class="logo">瓢城旅行社</h1>
<nav class="link">
<h2 class="none">网站导航</h2>
<ul>
<li class="active"><a href="index.html">首页</a></li>
<li><a href="information.html"><span class="xs-hidden">旅游</span>资讯</a></li>
<li><a href="ticket.html">机票<span class="xs-hidden">订购</span></a></li>
<li class="xs-hidden"><a href="scenery.html">风景欣赏</a></li>
<li><a href="about.html"><span class="xs-hidden">关于</span>公司</a></li>
</ul>
</nav>
</div>
</header>

<div id="adver">
<img src="img/adver.jpg" >
<div class="center"></div>
<div class="center copy">
<input type="text" class="search" placeholder="请输入旅游景点或城市">
<button class="button">搜索</button>
</div>
</div>

<footer id="footer">
<div class="top sm-hidden">
<div class="block left">
<h2>合作伙伴</h2>
<hr>
<ul>
<li>途牛旅游网</li>
<li>驴妈妈旅游网</li>
<li>携程旅游</li>
<li>中国青年旅行社</li>
</ul>
</div>
<div class="block center">
<h2>旅游FAQ</h2>
<hr>
<ul>
<li>旅游合同签订方式?</li>
<li>儿童价是基于什么制定的?</li>
<li>旅游的线路品质怎么界定的?</li>
<li>单房差是什么?</li>
<li>旅游保险有那些种类?</li>
</ul>
</div>
<div class="block right">
<h2>联系方式</h2>
<hr>
<ul>
<li>微博:weibo.com/ycku</li>
<li>邮件:[email protected]</li>
<li>地址:江苏盐城无名路123号</li>
</ul>
</div>
</div>
<div class="clearfix"></div>
<div class="version sm-visible">
客户端 | 触屏版 | 电脑版
</div>
<div class="bottom">
Copyright © YCKU 瓢城旅行社 | 苏ICP备120110119号<span class="sm-hidden"> | 旅行社经营许可证:L-YC-BK12345</span>
</div>
</footer>

</body>
</html>

 

@charset "utf-8";

body,h1,h2,h3,p,ul,ol,form,fieldset,figure {
margin: 0;
padding: 0;
}
div,figure,img,input,button {
box-sizing: border-box;
}
body {
background-color: #f5f5f5;
font-family: "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei UI", "Microsoft YaHei", SimHei, "5B8B4F53", simsun, sans-serif;
}
img {
display: block;
max-width: 100%;
}
ul,ol {
list-style: outside none none;
}
a {
text-decoration: none;
}
.none {
display: none;
}
.sm-visible {
display: none;
}
.clearfix:after {
content:".";
height:0;
visibility:hidden;
display:block;
clear:both;
}
#header {
width: 100%;
height: 70px;
background-color: #333;
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
position: fixed;
top: 0;
z-index: 9999;
}
#header .center {
max-width: 1263px;
height: 70px;
margin: 0 auto;
}
#header .logo {
width: 30%;
height: 70px;
background: url(../img/logo.png) no-repeat left center;
text-indent: -9999px;
float: left;
}
#header .link {
width: 55%;
height: 70px;
line-height: 70px;
color: #eee;
float: right;
}
#header .link li {
width: 20%;
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: 1920px;
margin: 0 auto;
padding: 70px 0 0 0;
position: relative;
}
#adver .center {
width: 40%;
height: 60px;
background-color: #000;
position: absolute;
top: 50%;
left: 50%;
margin: -10px 0 0 -20%;
opacity: 0.6;
border-radius: 10px;
}
#adver .copy {
opacity: 1;
background-color: transparent;
padding: 3px 3px 0 3px;
}
#adver .search {
width: 70%;
height: 52px;
background-color: #eee;
color: #666;
border: 1px solid #666;
border-radius: 10px;
font-size: 24px;
padding: 0 10px;
outline: none;
display: block;
float: left;
}
#adver .button {
width: 30%;
height: 54px;
background-color: #eee;
color: #666;
border: 1px solid #333;
border-left-width: 3px;
border-radius: 10px;
font-size: 24px;
outline: none;
cursor: pointer;
font-weight: bold;
display: block;
float: right;
}
#footer {
background-color: #222;
clear:both;
position: relative;
top: 20px;
}
#footer .top {
max-width: 1263px;
height: 280px;
margin: 0 auto;
text-align: center;
}
#footer .version {
color: #777;
text-align: center;
padding: 10px 0;
}
#footer .block {
width: 33.33%;
height: 320px;
display: inline-block;
color: #ccc;
text-align: left;
vertical-align: top;
display: block;
float: left;
}
#footer .bottom {
padding: 15px 0;
text-align: center;
color: #777;
background-color: #000;
border-top: 1px solid #444;
}
#footer h2 {
font-weight: normal;
padding: 20px 0 0 20px;
font-size: 24px;
}
#footer hr {
width: 90%;
border: 1px dashed #333;
}
#footer ul {
color: #666;
font-size: 18px;
text-indent: 20px;
line-height: 2;
}

 


/*媒体查询,参考部分Bootstrap 框架*/
/*当页面大于1200px 时,大屏幕,主要是PC 端*/
@media (min-width: 1200px) {

}
/*在992 和1199 像素之间的屏幕里,中等屏幕,分辨率低的PC*/
@media (min-width: 992px) and (max-width: 1199px) {
#adver .center {
width: 50%;
margin: -10px 0 0 -25%;
}
}
/*在768 和991 像素之间的屏幕里,小屏幕,主要是PAD*/
@media (min-width: 768px) and (max-width: 991px) {
#adver .center {
width: 60%;
margin: -10px 0 0 -30%;
}
#adver .search, #adver .button {
font-size: 20px;
}
}
/*在480 和767 像素之间的屏幕里,超小屏幕,主要是手机*/
@media (min-width: 480px) and (max-width: 767px) {
#header, #header .center, #header .link {
height: 45px;
}
#header .logo, .sm-hidden {
display: none;
}
#header .link {
width: 100%;
line-height: 45px;
}
#adver {
padding: 45px 0 0 0;
}
#adver .center {
width: 70%;
height: 53px;
margin: -10px 0 0 -35%;
}
#adver .search, #adver .button {
height: 45px;
font-size: 18px;
}
.sm-visible {
display: block;
}
}
/*在小于480 像素的屏幕,微小屏幕,更低分辨率的手机*/
@media (max-width: 479px) {
#header, #header .center, #header .link {
height: 45px;
}
#header .logo, .xs-hidden, .sm-hidden {
display: none;
}
#header .link {
width: 100%;
line-height: 45px;
}
#header .link li {
width: 25%;
}
#adver {
padding: 45px 0 0 0;
}
#adver .center {
width: 80%;
height: 48px;
margin: -10px 0 0 -40%;
}
#adver .search, #adver .button {
height: 40px;
font-size: 16px;
}
.sm-visible {
display: block;
}
#footer .bottom, #footer .version {
font-size: 13px;
}
}

 

第33章项目实战-兼容式响应布局3

第33章项目实战-兼容响应式布局[3]学习要点:1.标题响应式2.图片响应式本章主要开始如果将前两个项目再进行重构,设计成既可以在PC端正常显示,又可以在PAD上浏览,还可以在移动端有良好的体验。这些都必须兼容,那只有使... 查看详情

第33章项目实战-兼容式响应布局6

第32章项目实战-移动端流体布局[6]学习要点:1.旅游资讯2.机票预定本章主要开始如果通过第一个PC端项目进行重构,设计成移动端可访问的页面,这个项目采用的是流体布局。一.旅游资讯这个如果做成移动端,那么一切从简,... 查看详情

原理+实战快速掌握响应式开发

...统2-9分而治之&预处理工具2-10JavaScript2-11调试方法第3章项目实战-音乐社区官网首页从环境搭建,到页面各部分代码编写,再到模拟调试,多设备浏览,gulp插件集成。完整实现一个音乐社区类的官网首页,把前面的知识融汇到... 查看详情

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

第32章项目实战-移动端流体布局[3]学习要点:1.搜索部分2.旅游部分3.媒体查询本章主要开始如果通过第一个PC端项目进行重构,设计成移动端可访问的页面,这个项目采用的是流体布局。一.搜索部分搜索部分包含三个内容,背... 查看详情

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

第32章项目实战-移动端流体布局[6]学习要点:1.旅游资讯2.机票预定本章主要开始如果通过第一个PC端项目进行重构,设计成移动端可访问的页面,这个项目采用的是流体布局。一.旅游资讯这个如果做成移动端,那么一切从简,... 查看详情

第31章项目实战-pc端固定布局9

第31章项目实战-PC端固定布局[8]学习要点:1.资讯内容2.代码详解本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.资讯内容和首页一样,只不过这里,布局方式有所不同,具体如下:二... 查看详情

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

第32章项目实战-移动端流体布局[5]学习要点:1.导航固顶2.三个栏目3.公司简介本章主要开始如果通过第一个PC端项目进行重构,设计成移动端可访问的页面,这个项目采用的是流体布局。一.导航固定由于移动设备屏幕高度较低... 查看详情

第31章项目实战-pc端固定布局10

第31章项目实战-PC端固定布局[10]学习要点:1.机票预定2.代码详解本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.机票预定机票预定页面,具体如下:二.代码详解//全部代码<formactio... 查看详情

第31章项目实战-pc端固定布局4

第31章项目实战-PC端固定布局[4]学习要点:1.热门旅游区2.标题介绍区3.旅游项目区本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.热门旅游区本节课,我们将探讨一下首页最核心的部... 查看详情

第31章项目实战-pc端固定布局8

第31章项目实战-PC端固定布局[8]学习要点:1.归类合并2.子导航本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.归类合并在前面几节课中,有一部分HTML代码比较松散,没有统一到一个类... 查看详情

第31章项目实战-pc端固定布局3

第31章项目实战-PC端固定布局[3]学习要点:1.搜索区2.插入大图3.搜索框本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.搜索区本节课,我们接着header头部往下,来设计一块搜索区。这... 查看详情

第31章项目实战-pc端固定布局5

第31章项目实战-PC端固定布局[5]学习要点:1.底部区域2.说明区域3.版权及证件区本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.底部区域本节课,我们将探讨一下首页中最底部的区域... 查看详情

第31章项目实战-pc端固定布局7

第31章项目实战-PC端固定布局[7]学习要点:1.侧栏制作2.详细代码本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.侧栏制作本节课,主要设计一下内容页面的侧栏部分,分三个小块。经... 查看详情

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

第32章项目实战-移动端流体布局[4]学习要点:1.旅游图片部分本章主要开始如果通过第一个PC端项目进行重构,设计成移动端可访问的页面,这个项目采用的是流体布局。一.旅游图片部分//HTML部分<divclass="container"><figure>... 查看详情

响应式开发一招致胜

...样分析设计图1-10响应式网站设计实践原则第2章如何组织项目目录结构介绍了约定优于配置的思想,常见的项目目录和文件的组织方式,一些基本文件的作用等知识,为编码开始做准备。2-1简述2-2文件夹的组织2-3有用的文件1(rob... 查看详情

精通高级rxjava2响应式编程思想

...。先简单介绍和回顾RxJava,之后进入源码分析,再以实战项目来加深 查看详情

第31章项目实战-pc端固定布局6

第31章项目实战-PC端固定布局[6]学习要点:1.分离CSS2.头部区域3.内容区域本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端固定布局来实现。一.分离CSS本节课,我们将要创建一个新的页面:旅游资讯。那么... 查看详情

java响应式编程springbootwebflux基础与实战

第1章课程介绍课程介绍及导学1-1导学第2章函数式编程和lambda表达式本章介绍函数式编程的概念,和lambda表达式的基础语法,并分析了惰性求值的应用和实现。最后同意反编译字节码,重点剖析了lambda表达式的底层实现原理2-1概... 查看详情