当前位置: 首页 > news >正文

用CSS创造三角形案例

6.3.2 用CSS创造三角形

用div来创建,角上是平分的,所以要是内部宽高为0,其他边透明,正好是三角形。

代码

div {border: 12px solid;width: 0;height: 0;border-color: transparent red transparent transparent;
}

与伪元素after结合起来,在6.3.弹出层.html中增加CSS:

<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title><style>figure {width: 144px;height: 153px;margin: 20px 20px;border: 1px solid #666;position: relative;float: left;}img {width: 144px;height: 153px;display: block;}figcaption {display: none;/* 隐藏弹出层 */position: absolute;/* 相对于容器 */left: 74%;/* 放到右边 */top: 15px;width: 130px;/* 弹出层宽度 */padding: 10px;/* 弹出层内边距 */background-color: #f2eaea;border: 3px solid red;border-radius: 6px;}/* 鼠标悬停在图片上显示 */figure:hover figcaption {display: block;}figcaption h3 {/*弹出层的内容*/font-size: 14px;color: #666;margin-bottom: 6px;}figcaption a {/*弹出层的内容*/display: block;text-decoration: none;font-size: 12px;color: #000;}/* 把弹出层设置为最高层 */figure:hover figcaption {display: block;z-index: 2;}/* 红色三角形盒子 */figcaption::after {content: "";position: absolute;border: 12px solid;border-color: transparent red transparent transparent;height: 0px;width: 0px;top: 17px;right: 100%;}</style>
</head><body><figure><img src="img/pink.jpg" alt="pink heels" /><figcaption><h3>Pink Platforms</h3><a href="#">More info</a></figcaption></figure><figure class="click_me"><img src="img/baowen.jpg" alt="baowen heels" /><figcaption><h3>Leopard Platforms</h3><a href="#">More info</a></figcaption></figure><figure class="click_me"><img src="img/red.jpg" alt="red heels" /><figcaption><h3>Red Platforms</h3><a href="#">More info</a></figcaption></figure>
</body></html>


http://www.mrgr.cn/news/41104.html

相关文章:

  • 健康信息管理:SpringBoot的创新应用
  • 二、创建drf纯净项目
  • 【前沿 热点 顶会】NIPS 2024中与强化学习有关的论文
  • 【P5657 [CSP-S2019] 格雷码】
  • 电影推荐系统
  • 开放式耳机哪个品牌好?值得选购的开放式蓝牙耳机推荐
  • 校园健康数据管理:SpringBoot技术优势
  • Ref-NeuS参数记录
  • ThreadLocal原理解析及面试
  • 大语言模型入门(二)——提示词
  • 金融领域的人工智能——Palmyra-Fin 如何重新定义市场分析
  • 【CViT】Deepfake Video Detection Using Convolutional Vision Transformer
  • 互联网大厂软件开发背后的秘密:为何瀑布和 Scrum 模式备受青睐?
  • 【linux进程】进程优先级命令行参数环境变量
  • 【mmengine】优化器封装(OptimWrapper)(入门)优化器封装 vs 优化器
  • 试用模方软件时,在编辑模型视图下操作较卡,模型分辨率是3厘米,重建时设置平面划分的瓦片大小是450米,划分瓦片的时候大小设置多少比较合适?
  • 如何使用ssm实现基于JSP的高校听课评价系统
  • WPF下使用FreeRedis操作RedisStream实现简单的消息队列
  • 适用于 Windows 10 的最佳 PDF 编辑器列表,可帮助更改 PDF 文件。
  • ConcurrentLinkedQueue的核心方法有哪些?