我决定了每周写一篇博客,分享自己所学的知识,这周是个简单的旅游网页制作。
这是效果图:
编写这个旅游网页利用BootStrap框架可以分为头部,正文,底部 3个部分。再在每个部分一一实现相应的功能。
1、头部主要要实现两个功能:搜索框和导航条。导航条利用BootStrap组件实现。
2、正文部分:’BootStrap栅格系统实现。
3、底部:添加张图片即可(我这里做得很简单哈)。
源码链接在底部:想要的话自行下载!
利用BootStrap组件的前提是需要先导入BootStrap的js插件,去BootStrap官网可下载。
下面直接放源码:
index.html
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>小葵花旅游网title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/index.css" rel="stylesheet">
<script src="js/jquery-3.2.1.min.js">script>
<script src="js/bootstrap.min.js">script>
head>
<body>
<header class="container-fluid">
<div class="row">
<img src="img/top_banner.jpg" class="img-responsive">
div>
<div class="row padd-top">
<div class="col-md-12 padd-top search">
<input class="search_input" type="text" placeholder="请输入线路名称">
<a class="search_button" href="#">搜索a>
div>
div>
<div class="row">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="glyphicon glyphicon-th-list" style="color: white">span>
button>
div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">首页a>li>
<li><a href="#">机票a>li>
<li><a href="#">酒店a>li>
<li><a href="#">火车票a>li>
<li><a href="#">汽车票a>li>
<li><a href="#">特价线路a>li>
<li><a href="#">门票a>li>
<li><a href="#">周边游a>li>
<li><a href="#">租车a>li>
<li><a href="#">攻略a>li>
ul>
div>
div>
nav>
div>
<div class="row">
<div id="carousel-example-generic" data-interval="2000" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active">li>
<li data-target="#carousel-example-generic" data-slide-to="1">li>
<li data-target="#carousel-example-generic" data-slide-to="2">li>
ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="img/banner_1.jpg">
<div class="carousel-caption">
墨西哥
div>
div>
<div class="item">
<img src="img/banner_2.jpg" alt="...">
<div class="carousel-caption">
土耳其
div>
div>
<div class="item">
<img src="img/banner_3.jpg" alt="...">
<div class="carousel-caption">
北海道
div>
div>
div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true">span>
<span class="sr-only">Previousspan>
a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true">span>
<span class="sr-only">Nextspan>
a>
div>
div>
header>
<div class="container">
<div class="row">
<div class="jx_top">
<img src="img/icon_5.jpg">
今日推荐
div>
div>
<div class="row">
<div class="col-md-3">
<div class="thumbnail">
<img src="img/jingxuan_1.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-3">
<div class="thumbnail">
<img src="img/jingxuan_2.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-3">
<div class="thumbnail">
<img src="img/jingxuan_3.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-3">
<div class="thumbnail">
<img src="img/jingxuan_4.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
div>
<div class="row">
<div class="jx_top">
<img src="img/icon_6.jpg">
国内游
div>
div>
<div class="row">
<div class="col-md-4">
<img src="img/guonei_1.jpg" class="img-responsive">
<img src="img/guonei_2.jpg" class="img-responsive">
div>
<div class="col-md-8">
<div class="col-md-4">
<div class="thumbnail">
<img src="img/jingxuan_1.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-4">
<div class="thumbnail">
<img src="img/jingxuan_2.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-4">
<div class="thumbnail">
<img src="img/jingxuan_3.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-4">
<div class="thumbnail">
<img src="img/jingxuan_4.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-4">
<div class="thumbnail">
<img src="img/jingxuan_5.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
<div class="col-md-4">
<div class="thumbnail">
<img src="img/jingxuan_6.jpg" alt="...">
<div class="caption">
<p>上海直飞三亚5天4晚自由行(春节预售+亲子/蜜月/休闲游首选+豪华酒店任选+接送机)p>
<span style="color: red">¥888span>
div>
div>
div>
div>
div>
div>
<footer class="container-fluid">
<div class="row">
<img src="img/footer_service.png" class="img-responsive">
div>
footer>
body>
html>
index.css
* {
padding: 0px;
margin: 0px;
}
a:link {
color: black;
text-decoration: none;
}
a:hover {
color: orange;
text-decoration: none;
}
.padd-top {
padding-top: 10px;
}
.search_input {
/* 宽400,高36,左浮动,边框2,颜色#ffc900,左内边距10,外轮廓outline设置为0*/
width: 400px;
height: 36px;
float: left;
border: 2px solid #ffc900;
padding-left: 10px;
outline: 0px;
}
.search_button {
/*点击按钮,是一个链接:左浮动,宽90,高36,背景色#ffc900,行高36,文本居中*/
float: left;
width: 90px;
height: 36px;
background-color: #ffc900;
text-align: center;
line-height: 36px;
}
.jx_top {
/*外上边距15px, 底部边框2px 实线 #ffc900做为下面的线,
宽度100%,高度35px,行高35px,外下边距5px。图标文件:icon_5.jpg*/
margin-top: 15px;
border-bottom: 2px solid #ffc900;
width: 100%;
height: 35px;
line-height: 35px;
margin-bottom: 5px;
}
.company {
/*字体大小12,背景色#ffc900,文字居中对齐,高度与行高为40px*/
font-size: 12px;
background-color: #ffc900;
text-align: center;
height: 40px;
line-height: 40px;
}
.search{
margin-left:500px;
margin-top:20px;
margin-bottom:20px;
}
总结:制作中的巧妙之处有:1、用BootStrap的组件很快的实现轮播效果和导航栏。
2、用container容器很好的解决了图片布局问题。因为网页中中间部分的布局是一张大图片加三张小图片,而row属性一行有12列,怎么能更好的划分这四张图片呢?,这里就聪明的把大图片占四列,其他三张占8列,再在这8列的基础上每张图片占四列,就把这问题OK掉了。
这是源码哈:https://download.csdn.net/download/weixin_42490117/11505119