一、效果图
京东效果
模拟的效果
二、原理
准备一个高度和宽度为0的盒子
将这个盒子设置一个边框
将边框不需要的地方用 transparent
来代替,需要显示的地方设置对应的颜色
如果需要改变其大小,直接设置边框的宽度 border-width
将字体 font-size
和行高 line-height
设置为0,以免影响显示
最后使用定位将其设置到需要的位置
三、代码
html结构
<div class="square"> <p class="triangle"></p> </div>
css样式
.square { position: relative; width: 400px; height: 200px; background: green; margin: 150px auto; } .triangle { position: absolute; top: -40px; left: 50%; margin-left: -20px; width: 0; height: 0; border-style: solid; border-width: 20px; border-color: transparent transparent red transparent; font-size: 0; line-height: 0; }
到此这篇关于css聊天气泡的文章就介绍到这了,更多相关css聊天气泡内容请搜索移动技术网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持移动技术网!
如对本文有疑问, 点击进行留言回复!!
清除新版Google Chrome浏览器中表单控件(input,button...)默认的黑色边框
荐 20200714——git/mac配置/项目运行步骤/一些报错
antd 菜单组件 使用时报错:Cannot read property ‘isRootMenu‘ of undefined
CSS|div的style=“background-image: url(img/a.bmp)图片显示不出来
硬件仪表盘账号建立指导(一) --WHQL认证测试结果提交账号(一)
cookie的规范Cookie的不可跨域名性或Cookie与域名的关系
网友评论