用CSS创造三角形案例

news/2024/10/7 17:45:36 标签: 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.niftyadmin.cn/n/5693131.html

相关文章

005集—— 用户交互之CAD窗口选择图元实体(CAD—C#二次开发入门)

如下图&#xff1a;根据提示选择若干图形要素&#xff0c;空格或右键结束选择&#xff0c;返回图元的objectid&#xff0c;以便进一步操作图元实体。 代码如下&#xff1a; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.Aut…

卡码网104.建造最大岛屿

题目 104. 建造最大岛屿 (kamacoder.com) 代码&#xff08;ACM 首刷看解析&#xff09;&#xff1a; #include<iostream> #include<vector> #include<unordered_map> #include<unordered_set> using namespace std;int dir[4][2] {1,0,-1,0,0,1,0,-…

《Cloud Native Data Center Networking》(云原生数据中心网络设计)读书笔记 -- 12数据中心中的EVPN

研究数据中心如何进行网络虚拟化配置之前&#xff0c;我们需要熟悉 EVPN的基础知识。如前所述&#xff0c;EVPN是一种为网络虚拟化提供控制平面的解决方案。用最简单的术语来说&#xff0c;EVPN是一种连接被三层网络分隔的二层网段的技术。EVPN通过在三层网络之上构建出一个叠加…

如何判断静态代理IP地址是否被污染?

在网络使用中&#xff0c;静态IP代理是一种常见的工具&#xff0c;用于维持稳定的连接和保护个人隐私。然而&#xff0c;有时这些IP地址可能会被污染&#xff0c;导致用户遭受各种问题&#xff0c;如连接延迟、数据泄露等。因此&#xff0c;了解如何判断址是否被污染至关重要。…

C嘎嘎入门篇:类和对象番外(时间类)

前文&#xff1a; 小编在前文讲述了类和对象的一部分内容&#xff0c;其中小编讲述过运算符重载这个概念以及一个时间类&#xff0c;当时小编讲的没有那么细致&#xff0c;下面小编将会讲述时间类来帮助各位读者朋友更好的去理解运算符重载&#xff0c;那么&#xff0c;代码时刻…

推理攻击-Python案例

1、本文通过推理攻击的方式来估计训练集中每个类别的样本数量、某样本是否在训练集中。 2、一种简单的实现方法&#xff1a;用模型对训练数据标签进行拟合&#xff0c;拟合结果即推理为训练集中的情况。 3、了解这些案例可以帮助我们更好的保护数据隐私。 推理攻击&#xff08;…

微服务获取用户信息和OpenFeign传递用户

问题一&#xff1a; 网关已经完成登录校验并获取登录用户身份信息。但是当网关将请求转发到微服务时&#xff0c;微服务又该如何获取用户身份呢&#xff1f; 由于网关发送请求到微服务依然采用的是Http请求&#xff0c;因此我们可以将用户信息以请求头的方式传递到下游微服务…

【YOLOv8实时产品缺陷检测】

YOLOv8应用于产品缺陷检测实例 项目概况项目实现YOLOv8安装及模型训练关键代码展示动态效果展示 项目概况 本项目是应用YOLOv8框架实现训练自定义模型实现单一零件的缺陷检测&#xff0c;软件界面由PyQt5实现。 功能已正式使用&#xff0c;识别效果达到预期。 项目实现 项目…