带三角箭头的悬浮提示

画一个三角形:容器宽高为0;其中一条border 有颜色、实线、宽度;其余三条border 宽度、实线、transparent。

        .shape {
            width: 0;
            height: 0;
            border-left: 50px solid blue;
            border-right: 50px solid transparent;
            border-top: 50px solid transparent;
            border-bottom: 50px solid transparent ;
            background: white;
         }

<!DOCTYPE html>
<html>

<head>
	<style type="text/css">
		body {
			text-align: center;
		}

		.tooltip {
			position: relative;
			color: black;
			display: inline-block;
		}

		.tooltiptext {
			visibility: hidden;
			width: 150px;
			color: white;
			background-color: black;
			position: absolute;
			border-radius: 4px;
			padding: 5px;
			top: 150%;
			left: 50%;
			margin-left: -75px;
			z-index: 1;
		}

		.tooltip:hover .tooltiptext {
			visibility: visible;
		}

		.tooltiptext::after {
			content: " ";
			position: absolute;
			bottom: 100%;
			/* At the top of the tooltip */
			right: 50%;
			margin-left: -5px;
			border-width: 5px;
			border-style: solid;
			border-color: transparent transparent black transparent;
			/* 调换border-color中的颜色来查看箭头的位置,再结合position 来放置箭头在边框的位置 */
		}

		.main {
			margin: 60px auto;
			width: fit-content;
		}
		.shape {
			width: 0;
			height: 0;
			border-left: 50px solid blue;
			border-right: 50px solid ;
			border-top: 50px solid transparent;
			border-bottom: 50px solid ;
			background: white;
		}
	</style>
	<meta charset="utf-8">
	<title></title>
</head>

<body>
	<div class="tooltip">
		鼠标移到我身上
		<span class="tooltiptext">哈哈,这个是一个提示</span>
	</div>

	<div class="main">
		<div class="shape"></div>
	</div>
	
</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值