登录  /  注册

css实现箭头和带缺口提示框

jacklove
发布: 2018-06-20 16:00:11
原创
2359人浏览过

一、实现如图所示箭头

<!DOCTYPE html>
<html>
<head>
	<title></title>
<style type="text/<a style='color:#f60; text-decoration:underline;' href="https://www.php.cn/zt/15716.html" target="_blank">css</a>">
.out{
	width: 200px;
	height: 200px;
	background: #f00;
	position: relative;
}
.word{
	position: absolute;
	left: 60px;
	line-height: 40px;
}
.triangle-out{
	position: absolute;
	top: 0px;
	left: 0px;
	width: 0px;
	height: 0px;
	display: block;
	border-top: 20px solid #f00;
	border-right: 20px solid #f00;
	border-bottom: 20px solid #f00;
	border-left: 40px solid #ff0;
}
.triangle-in{
	position: absolute;
	top: 0px;
	left: 0px;
	width: 0px;
	height: 0px;
	display: block;
	border-top: 20px solid transparent;
	border-right: 20px solid transparent;
	border-bottom: 20px solid transparent;
	border-left: 20px solid #f00;
}
</style>
</head>
<body>
	<p class="out">
		<span class="triangle-out"></span>
		<span class="triangle-in"></span>
		<span class="word">read more</span>
	</p>
</body>
</html>
登录后复制

二、实现带缺口提示框


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>带缺口的提示框-/</title>
<style>
.wrap{
	font-size: 12px;
	margin:40px auto;
	width:600px;
}
.ui-slider-tooltip{
	background:#FCFDFD; 
	border:1px solid green;
	color:#222222;
	display: block;
	text-align: center;
	padding: 5px 3px 5px 3px;
	width: 190px;	
	position: relative; 
}
.ui-corner-all {
	-moz-border-radius-bottomleft:5px;
	-moz-border-radius-bottomright:5px;
	-moz-border-radius-topleft:5px;
	-moz-border-radius-topright:5px;
	-webkit-border-top-left-radius:5px 5px;
	-webkit-border-top-right-radius:5px 5px;
	-webkit-border-bottom-right-radius:5px 5px;
	-webkit-border-bottom-left-radius:5px 5px;
}
.ui-tooltip-pointer-down {
	border-bottom-width: 0;
	border-left: 7px dashed transparent; 
	border-right: 7px dashed transparent;
	border-top: 8px solid green;
	bottom:	-8px;
	display: block;
	height:0;
	left: 50%;
	margin-left: -7px;
	position: absolute; 
	width:0;
}

.ui-tooltip-pointer-down-inner {
	border-left: 6px dashed transparent; 
	border-right: 6px dashed transparent;
	border-top: 7px solid #fff;
	left: -6px;
	top: -9px;
	position: absolute; 
}

.a{
	display: block;width:0;height:0;
	border-left: 7px dashed transparent; 
	border-right: 7px dashed transparent;
	border-top: 8px solid green;
	border-bottom: 0;
	position: absolute;
}
.b{
	position: absolute; 
	border-left: 6px dashed transparent; 
	border-right: 6px dashed transparent;
	border-top: 7px solid #fff;
	top: -9px;
	left: -6px;
}
</style>
</head>
<body>
<p class="wrap">
	<h1>用CSS实现带缺口的提示框</h1>
	<span class="a">
		<span class="b"></span>
	</span>
	<br/>
	<span class="a">
		<span class="b" style="top:-11px;"></span>
	</span>
	<br/>


	<span class="ui-slider-tooltip  ui-corner-all">
		<span>带缺口提示框</span>
		<span class="ui-tooltip-pointer-down">
		<span class="ui-tooltip-pointer-down-inner" ></span>
		</span>
	</span>
	<br/>
	<span class="ui-slider-tooltip  ui-corner-all" style="background: #f00">
		<span>加个背景就可以看清原理啦</span>
		<span class="ui-tooltip-pointer-down">
		<span class="ui-tooltip-pointer-down-inner" ></span>
		</span>
	</span>
</p>
</p>
</body>
</html>
登录后复制

其实就是利用宽度高度为0的box,设置border,得到想要的三角形,通过三角形的叠加显示制作出箭头的效果~

本文讲解了css实现箭头和带缺口提示框 ,更多相关内容请关注php中文网。

相关推荐:

前端工程师学习基础知识

关于JavaScript基础

关于面向对象设计的相关讲解的相关讲解

以上就是css实现箭头和带缺口提示框的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
关于CSS思维导图的课件在哪? 课件
凡人来自于2024-04-16 10:10:18
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号