css实战案例2:携程旅游首页上半部分

代码样式:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>

		<div class="search_box">
			<!-- 搜索框-->
			<div class="search">搜索:目的地/酒店/航班</div>
			<a class="user">我的</a>
		</div>
		
		<!-- 焦点图图-->
		<div class="focus">
			<img src="img/22.jpg"/>
		</div>
		
		
		<div class="nav_local">
			<ul>
				<li>
					<a class="nav_local_item">
						<img src="img/nav21.png" class="nav_local_item_icon"></img>
						<span  class="nav_local_item_text">景点*玩乐</span>
					</a>
				</li>
				<li>
					<a class="nav_local_item">
						<img src="img/nav22.png" class="nav_local_item_icon"></img>
						<span class="nav_local_item_text">周边游</span>
					</a>
				</li>
				<li>
					<a class="nav_local_item">
					<img src="img/nav23.png" class="nav_local_item_icon"></img>
						<span class="nav_local_item_text">美食林</span>
					</a>
				</li>
				<li>
					<a class="nav_local_item">
					<img src="img/nav24.png" class="nav_local_item_icon"></img>
						<span class="nav_local_item_text">一日游</span>
					</a>
				</li>
				<li>
					<a class="nav_local_item">
					<img src="img/nav25.png" class="nav_local_item_icon"></img>
						<span class="nav_local_item_text">当地攻略</span>
					</a>
				</li>
			</ul>
		</div>
		
		<!-- 主导航栏 -->
		<div class="nav">
			<div class="nav-common">
				<div class="nav-common-top">
					<a>海外酒店</a>
				</div>
				<div class="nav-common-top">
					<a>海外酒店</a>
					<a>特价酒店</a>
				</div>
				<div class="nav-common-top">
					<a>海外酒店</a>
					<a>特价酒店</a>
				</div>
			</div>
			<div class="nav-common">
				<div class="nav-common-top">
					<a>海外酒店</a>
				</div>
				<div class="nav-common-top">
					<a>海外酒店</a>
					<a>特价酒店</a>
				</div>
				<div class="nav-common-top">
					<a>海外酒店</a>
					<a>特价酒店</a>
				</div>
			</div>
			<div class="nav-common">
				<div class="nav-common-top">
					<a>海外酒店</a>
				</div>
				<div class="nav-common-top">
					<a>海外酒店</a>
					<a>特价酒店</a>
				</div>
				<div class="nav-common-top">
					<a>海外酒店</a>
					<a>特价酒店</a>
				</div>
			</div>
		</div>

	</body>
</html>


<style>
	a{
		text-decoration: none;
	}
	ul {
		list-style: none;
		margin: 0;
		padding: 0;
	}
	dic {
		box-sizing: border-box;
	}
	body {
		min-width: 320px;
		max-width: 540px;
		margin: 0 auto;
	}
	.search_box {
		position: fixed;
		top: 0;
		/*居中*/
		left: 50%;
		transform: translateX(-50%);
		/*transform 属性允许你旋转、缩放、倾斜或平移给定元素*/
		-webkit-transform: translateX(-50%);/*向左平移当前元素长度的一半*/
		/*兼容老浏览器写法*/
		width: 100%;
		min-width: 320px;
		max-width: 540px;
		height: 44px;
		display: flex;
	}

	.search {
		flex: 1; /*左边占一份*/
		height: 26px;
		line-height: 26px;
		border: 1px solid #ccc;
		margin: 7px 10px;
		border-radius: 5px;
		position: relative;
		padding-left: 25px;
		color: #707070;
		font-size: 13px;
		/*下边框阴影:x 偏移量 | y 偏移量 | 阴影模糊半径 | 阴影颜色*/
		box-shadow: 0px 2px 4px rgba(0, 0, 0,.4);
	}
	.search::before {
		content: "";
		background: url(img/search.png) no-repeat center;
		width: 20px;
		height: 20px;
		background-size:20px;
		
		/*使用绝对定位,让他浮出来,不占一行,因为后面还有文字*/
		top: 3px;
		left: 3px;
		position: absolute; /*默认是相对整个body的位置进行绝对定位,如果父级元素加了position: relative,就是相对于父级的位置进行绝对定位*/
	}
	
	
	/* CSS 伪元素 :before 和 :after 是两个强大的工具,它们允许我们在选定元素的前后插入内容,而无需修改HTML结构。这些伪元素通常与 content 属性一起使用,可以插入文本或图像。*/
	.user::before {
		content:"";
		background: url(img/my.png) no-repeat center;
		width: 17px;
		height: 17px;
		background-size:17px;
		display:block; /*此元素将显示为块级元素,此元素前后会带有换行符。*/
		margin: 0 auto; /*水平居中*/
	}
	.user {
		width: 44px;
		height: 44px;
		text-align: center;/*里面的文字水平居中*/
		font-size: 10px;
		padding-top: 8px;
		color: #1296db;
	}
	
	.focus img{
		width: 100%;
		margin-top:44px;;
	}
	.nav_local{
		padding: 4px;
	}
	.nav_local ul{
		height: 64px;
		border-radius: 8px;
		display: flex;
	}

	.nav_local li {
		/*均分*/
		flex: 1;
	}
	
	.nav_local_item {
		display: flex;
		/*主轴设置为y轴, 竖向排列*/
		flex-direction: column;
		/*副轴居中*/
		align-items: center;
	}
	.nav_local_item_icon {
		width: 32px;
		height: 32px;
	}
	.nav_local_item_text{
		font-size: 13px;
		color: #707070;
		margin-top: 2px;
	}

	.nav {
		border-radius: 8px;
		/*这里作用是让我们的圆角边框能显示*/
		overflow: hidden;/*溢出隐藏、清除浮动、解决外边距塌陷等等*/
	}
	
	.nav .nav-common {
		height: 88px;
		display: flex;
	}
	/*nth-child(n) 选择列表中的倒数第n个标签 n为数字*/
	.nav-common:nth-child(2){
		margin: 3px 0;
	}
	.nav-common-top {
		flex: 1;
		display: flex;
		flex-direction: column;
	}
	.nav-common-top a {
		flex: 1;
		line-height: 44px;
		color: #fff;
		font-size: 14px;
		/*文字阴影*/
		text-shadow: 1px 1px rgba(0, 0, 0,.2);
		text-align: center;
	}
	.nav-common-top a:nth-child(1){
		border-bottom: 1px solid #fff;
	}
	.nav-common-top:nth-child(1) a {
		border:0;
	}
	.nav-common-top:nth-child(1) a::after {
		content: "";
		background: url(img/hotel_ico.png) no-repeat center;
		display: block;
		background-size: 30px;
		width: 30px;
		height: 30px;
		margin-left: 50%;
		transform: translateX(-50%);
		/*transform 属性允许你旋转、缩放、倾斜或平移给定元素*/
		-webkit-transform: translateX(-50%);/*向左平移当前元素长度的一半*/
	}
	
	/*选择前两个元素*/
	.nav-common-top:nth-child(-n+2){
		border-right: 1px solid #fff;
	}
	
	.nav-common:nth-child(1) {
		/**从左到右,颜色线性渐变*/
		background:-webkit-linear-gradient(left , #FA5A55,#FA994D);
	}
	
	
	.nav-common:nth-child(2) {
		/**从左到右,颜色线性渐变*/
		background:-webkit-linear-gradient(left , #4B90ED,#53BCED);
	}
	
	
	.nav-common:nth-child(3) {
		/**从左到右,颜色线性渐变*/
		background:-webkit-linear-gradient(left , #34C2A9,#6CD559);
	}
	
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值