2021-08-20

CSS用户界面样式

鼠标样式cursor

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<ul>
			<li style="cursor: default">默认的小白鼠标样式</li>
			<li style="cursor: pointer">小手鼠标样式</li>
			<li style="cursor: move">移动鼠标样式</li>
			<li style="cursor: text">文本鼠标样式</li>
			<li style="cursor: not-allowed">禁止鼠标样式</li>
		</ul>
	</body>
</html>

轮廓线 outline

防止拖拽文本域 resize

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			input,textarea {
				outline: none;
			}
			textarea {
				resize: none; 
			}
		</style>
	</head>
	<body>
		<input type="text">
		<textarea name="" id="" cols="30" rows="10"></textarea>
	</body>
</html>

vertical-align属性应用

 

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			img {
				/* 让图片和文字垂直居中 */
				vertical-align: middle;
			}
			textarea {
				vertical-align: middle;
			}
		</style>
	</head>
	<body>
		<img src="images/curry.jpg" alt=""> 勇士总冠军,库里FMVP
		
		<br>
		<br>
		<textarea name="" id="" cols="30" rows="10"></textarea> 请你留言
	</body>
</html>

 

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			div {
				border: 2px solid pink;
			}
			img {
				vertical-align: bottom;
			}
		</style>
	</head>
	<body>
		<div>
			<img src="images/curry.jpg" alt=""> curry
		</div>
	</body>
</html>

常见的布局技巧

margin负值的运用

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
		
			ul li {
				position: relative;
				float: left;
				width: 150px;
				height: 200px;
				border: 1px solid red;
				list-style: none;
				margin-left: -1px;
			}
			/* ul li:hover {
				/* 1.如果盒子没有定位,则鼠标经过添加相对定位即可 */
				/* position: relative; */
				/* border: 1px solid blue; */
			 /* } */
			ul li:hover {
				/* 2.如果li都有定位,则利用z-index提高层级 */
				z-index: 1;
				border: 1px solid blue;
			}
		</style>
	</head>
	<body>
		<ul>
			<li>1</li>
			<li>2</li>
			<li>3</li>
			<li>4</li>
			<li>5</li>
		</ul>
	</body>
</html>

文字围绕浮动元素

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}	
			.box {
				width: 390px;
				height: 100px;
				background-color: pink;
				margin: 100px auto;
				padding: 5px;
			}
			.pic {
				float: left;
				width: 155px;
				height: 100px;
				margin-right: 10px;
			}
			.pic img {
				width: 100%;
				height: 100%;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="pic">
				<img src="images/curry.jpg" alt="">
			</div>
			<p>夏季联赛17日综述:状元休战活塞1分险胜魔术 马刺25分惨败雷霆</p>
		</div>
	</body>
</html>

行内块巧妙运用

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}
			.box {
				text-align: center;
				margin: 100px;
			}
			.box a {
				display: inline-block;
				width: 36px;
				height: 36px;
				background-color: #f7f7f7;
				border: 1px solid #ccc;
				text-align: center;
				line-height: 36px;
				text-decoration: none;
				color: #333;
				font-size: 14px;
			}
			.box .prev,
			.box .next {
				width: 85px;
			}
			.box .current,
			.box .elp {
				background-color: #fff;
				border: none;
			}
			.box input {
				width: 45px;
				height: 36px;
				border: 1px solid #ccc;
				outline: none;
			}
			.box button {
				width: 60px;
				height: 36px;
				border: 1px solid #ccc;
				background-color: #f7f7f7;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<a href="#" class="prev">&lt;&lt;上一页</a>
			<a href="#" class="current">1</a>
			<a href="#">2</a>
			<a href="#">3</a>
			<a href="#">4</a>
			<a href="#">5</a>
			<a href="#">6</a>
			<a href="#" class="elp">...</a>
			<a href="#" class="next">&gt;&gt;下一页</a>
			到第
			<input type="text">
			页
			<button>确定</button>
		</div>
	</body>
</html>

CSS三角强化

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			.box-1 {
				width: 0;
				height: 0;
				border-top: 50px solid pink;
				border-right: 50px solid red;
				border-bottom: 50px solid purple;
				border-left: 50px solid mediumpurple;
				margin: 50px auto;
			}
			.box-2 {
				width: 0;
				height: 0;
				border-top: 100px solid transparent;
				border-right: 50px solid red;
				border-bottom: 0 solid purple;
				border-left: 0 solid mediumpurple;
				margin: 50px auto;
			}
			.box-3 {
				width: 0;
				height: 0;
				border-color: transparent blue transparent transparent;
				border-style: solid;
				border-width: 100px 50px 0 0;
				margin: 50px auto;
			}
			.box-4 {
				position: relative;
				width: 300px;
				height: 100px;
				background-color: #ffffff;
				margin: auto;
			}
			.box-5 {
				float: left;
				width: 200px;
				height: 100px;
				background-color: purple;
			}
			.box-6 {
				position: absolute;
				left: 150px;
				width: 0;
				height: 0;
				border-color: transparent #ffffff transparent transparent;
				border-style: solid;
				border-width: 100px 50px 0 0;
			}
		</style>
	</head>
	<body>
		<div class="box-1"></div>
		<div class="box-2"></div>
		<div class="box-3"></div>
		<div class="box-4">
			<div class="box-5"></div>
			<div class="box-6"></div>
		</div>
	</body>
</html>

 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值