淘宝轮播图--web前端20200309学习笔记

1.外边距合并问题:解决方法

浮动元素,绝对定位(固定)元素都不会触发外边距合并问题

2.综合案例-淘宝轮播图

代码:
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		*{
			margin: 0;
			padding: 0;
		}
		li{
			list-style: none;
		}
		.taobao{
			margin:40px auto;
			width: 520px;
			height: 280px;
			background-color: pink;
			/*子绝父相*/
			position: relative;


		}
		.arrow-l{
			/*float:left;*/
			/*只能用定位才能压住盒子*/
			/*不要占有位置,随便移动位置,必须用绝对定位*/
			position: absolute;
			
			/*绝对定位的盒子无需转换,直接给大小就好了*/
			width: 20px;
			height: 30px;
			background: rgba(0,0,0, .2);
			/*垂直居中的公式*/
			/*1.走父级高度的50%*/
			top:50%;
			/*2.往上走 自己高度的一半*/
			margin-top:-15px;
			left: 0;
			/*去掉a的下划线*/
			text-decoration: none;
			/*圆角矩形*/
			/*右上角*/
			border-top-right-radius: 15px;
			/*右下角*/
			border-bottom-right-radius: 15px;
			color: white;
			line-height: 30px;
			text-align:left;

		}
		.arrow-r{
			/*float:left;*/
			/*只能用定位才能压住盒子*/
			/*不要占有位置,随便移动位置,必须用绝对定位*/
			position: absolute;
			
			/*绝对定位的盒子无需转换,直接给大小就好了*/
			width: 20px;
			height: 30px;
			background: rgba(0,0,0, .2);
			/*垂直居中的公式*/
			/*1.走父级高度的50%*/
			top:50%;
			/*2.往上走 自己高度的一半*/
			margin-top:-15px;
			right: 0;
			/*去掉a的下划线*/
			text-decoration: none;
			/*圆角矩形*/
			/*右上角*/
			/*border-top-left-radius: 15px;*/
			/*右下角*/
			/*border-bottom-left-radius: 15px;*/
			color: white;
			border-radius: 15px 0 0 15px;
			line-height: 30px;
			text-align: right;


		}
		.arrow-l:hover,
		.arrow-r:hover{
			background: rgba(0,0,0, .4);
		}
		.circle{
			position:absolute;
			bottom: 15px;
			/*水平居中*/
			left:50%;
			margin-left: -35px;
			width: 70px;
			height: 13px;
			background:rgba(255,255,255,0.3);
			border-radius: 7px;
		}
		.circle li{
			width: 8px;
			height: 8px;
			/*background-color: pink;*/
			background-color: #fff;
			float: left;
			border-radius: 50%;
			margin: 3px;
		}
		.circle .current{
			background-color: #ff5000;
		}

	</style>
</head>
<body>
	<div class="taobao">
	<!-- 左按钮 -->
	<a href="#" class="arrow-l">&lt;</a>
	<!-- 右按钮 -->
	<a href="#" class="arrow-r">&gt;</a>
	
	<img src="imgs/taobao.jpg" alt="">

	<!-- 小圆点 -->
	<ul class="circle">
	<li></li>
	<li class="current"></li>
	<li></li>
	<li></li>
	<li></li>
	</ul>
	</div>
</body>
</html>
运行结果:

在这里插入图片描述

2.1知识点补充--圆角矩形

圆角矩形可以分为4个角分别设置圆度,但是是有顺序的
boder-top-left-radius:20px;
boder-top-right-radius:20px;
border-bottom-right-radius:20px;
boder-bottom-left-radius:20px;

如果四个角数值相同

boder-radius:15px;

里面数值不同,我们也可以按照简写的形式,具体格式如下

boder-radius:左上角 右上角 右下角 左下角;

3.定位小结

在这里插入图片描述

注意:

  • 1.边偏移需要和定位模式联合使用,单独使用无效
  • top和bottom不要同时使用,left,right同理
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值