CSS图案设计

8 篇文章 0 订阅

1.边框的设计
边框
其中边框圆角、边框阴影属性,应用十分广泛,兼容性也相对较好,具有符合渐进增强原则的特征,我们需要重点掌握。

边框圆角

border-radius 每个角可以设置两个值 ,x 值,y 值
1: 边框圆角处理
2: 正方形

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width: 200px;
				height: 200px;
				margin: 100px auto;
				background-color: red;
				/* 四个角都是100px */
				/* border-radius: 100px 100px 100px 100px; */
				/* 1是50px 2、4是100px 3是50px */
				/* border-radius: 50px 100px 50px; */
				/* 1、3是100px 2、4是50px  */
				border-radius: 100px 50px;
			}
		</style>
	</head>
	<body>
		<div id="div1">
		</div>
	</body>
</html>

在这里插入图片描述
椭圆
圆角处理时,脑中要形成圆、圆心、横轴、纵轴的概念,正圆是椭圆的一种特殊情况。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width: 100px;
				height: 200px;
				margin: 100px auto;
				background-color: red;
				border-radius: 50px 50px 50px 50px/100px 100px 100px 100px;
			}
		</style>
	</head>
	<body>
		<div id="div1">
			
		</div>
	</body>
</html>

在这里插入图片描述
边框阴影

box-shadow 与 text/shadow 用法差不多
1、水平偏移量 正值向右 负值向左;
2、垂直偏移量 正值向下 负值向上;
box-shadow: 5px 5px 27px red, -5px -5px 27px green;
3、模糊度是不能为负值;
4、inset 可以设置内阴影;

box-shadow: 10px 10px 20px  aqua;

渐变

渐变是CSS3 当中比较丰富多彩的一个特性,通过渐变我们可以实现许多炫丽的效果,有效的减少图片的使用数量,并且具有很强的适应性和可扩展性。
可分为线性渐变、径向渐变

线性渐变 (gradient 变化)
linear-gradient 线性渐变指沿着某条直线朝一个方向产生渐变效果。
在这里插入图片描述
上图是从黄色渐变到绿色

Background:linear-gradient(yellow,green)

To right 表示方向 (left,top,right,left ,也可以使用度数)
Yellow, 渐变起始颜色
Green 渐变终止颜色
案例:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			body{
				background-color: salmon;
			}
			#div1{
				width: 200px;
				height: 200px;
				background-color: red;
				margin:100px  100px;
				border-radius:100px 100px/100px 100px ;
				box-shadow: 10px 10px 50px yellow,-10px -10px 50px  chartreuse;
				background: linear-gradient(140deg,red,blue);
				float: left;
			}
			
			/* #div2{
				width: 200px;
				height: 200px;
				background-color: brown;
				float: left;
				margin-top: 100px;
				margin-left: 100px;
				border-top-left-radius: 100px;
				border-top-right-radius: 100px;
			}
			#div3{
				width: 200px;
				height: 200px;
				background-color: brown;
				float: left;
				margin-top: 100px;
				margin-left: 100px;
				border-top-left-radius: 200px;
			}
			#div4{
				width: 200px;
				height: 200px;
				background-color: brown;
				float: left;
				margin-top: 100px;
				margin-left: 100px;
				border-top-right-radius: 200px;
			}
			#div5{
				width: 100px;
				height: 50px;
				background-color: brown;
				float: left;
				margin-top: 100px;
				margin-left: 100px;
				border-radius: 50px 50px 0 0;
			}
			#div6{
				width: 200px;
				height: 200px;
				float: left;
				border-left: 100px solid red;
				border-right: 100px solid wheat;
				border-top: 100px solid gainsboro;
				border-bottom: 100px solid transparent;
				box-sizing: border-box;
				margin-top: 100px;
				margin-left: 100px;
			} */
			#div7{
				width: 100px;
				height: 50px;
				background-color: brown;
				float: left;
				margin-top: 100px;
				margin-left: 100px;
				border-radius:60px/ 25px;
			}
			#div8{
				width: 100px;
				height: 50px;
				background-color: yellow;
				float: left;
				margin-top: 100px;
				margin-left: 100px;
				/* border-radius:60px/ 25px; */
				border-top-left-radius: 60px;
				border-bottom-right-radius: 60px;
				border-left: 30px solid #0000FF;
				border-right: 30px solid #0000FF;
				box-sizing: border-box;
			}
			#nose{
				width: 100px;
				height: 100px;
				clear: both;
				margin:auto;
				margin-top: 200px;
				box-sizing: border-box;
				border-bottom: 100px solid yellow;
				border-right: 50px solid transparent;
				border-left: 50px solid transparent;
			}
			#mouth{
				width: 200px;
				height: 100px;
				background-color: #0000FF;
				margin:auto;
				margin-top: 50px;
				border-radius: 0 0 100px 100px;
			}
			#big{
				width: 500px;
				height: 500px;
				background-color: bisque;
				float: left;
				border-top-left-radius: 150px;
				border-top-right-radius: 150px;
				border-bottom-left-radius: 200px;
				border-bottom-right-radius: 200px;
			}
			#arm1{
				width: 300px;
				height: 50px;
				background-color: #A52A2A;
				clear: both;
				margin-left: 300px;
				margin-top: 550px;
				position: absolute;
				border-radius: 100px 50px;
			}
			#bodyy{
				width: 300px;
				height: 500px;
				background-color: #7FFF00;
				border-radius:300px 300px;
				clear: both;
				float: left;
				margin-left: 500px;
			}
			#bagua{
				width: 200px;
				height: 200px;
				background: linear-gradient(blue,red);
				border-radius: 100px;
				float: left;
			}
			#b1{
				width: 100px;
				height: 100px;
				background-color: red;
				border-radius: 100px;
				margin-top: 50px;
				position: relative;
			}
			#b2{
				width: 50px;
				height: 50px;
				background-color: #7FFF00;
				border-radius: 50px;
				position: absolute;
				margin-top: 25px;
				margin-left: 25px;
			}
			#b3{
				width: 100px;
				height: 100px;
				background-color: blue;
				border-radius: 100px;
				margin-top: -100px;
				position: relative;
				float: right;
			}
			#b4{
				width: 50px;
				height: 50px;
				background-color: #7FFF00;
				border-radius: 50px;
				position: absolute;
				margin-top: 25px;
				margin-left: 25px;
			}
		</style>
	</head>
	<body>
		<div id="div1">
		</div>
		<div id="div2">
		</div>
		<div id="div3">
		</div>
		<div id="div4">
		</div>
		<div id="div5">
		</div>
		<div id="div6">
		</div>
		<div id="big">
			<div id="div7">
			</div>
			<div id="div8">
			</div>
			<div id="nose">
			</div>
			<div id="mouth">
			</div>
		</div>
		<div id="arm1">
			
		</div>
		<div id="bodyy">
		</div>
		<div id="bagua">
			<div id="b1">
				<div id="b2">
				</div>
			</div>
			<div id="b3">
				<div id="b4">
					
				</div>
			</div>
		</div>
	</body>
</html>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值