css之 斜线

方案一

复制代码
.x {
            border: solid 1px red;
            width: 100px;
            height: 100px;
            position: relative;
            background-color: transparent;
        }

            .x:before {
                position: absolute;
                top: 0px;
                right: 0;
                left: 0;
                bottom: 0;
                border-bottom: 100px solid red;
                border-left: 100px solid transparent;
                content: "";
            }

            .x:after {
                position: absolute;
                left: 1px;
                right: 0;
                top: 1px;
                bottom: 0;
                border-bottom: 99px solid white;
                border-left: 99px solid transparent;
                content: "";
            }

        .f {
            border: solid 1px red;
            width: 100px;
            height: 100px;
            position: relative;
            background-color: transparent;
        }

            .f:before {
                position: absolute;
                top: 0px;
                right: 0;
                left: 0;
                bottom: 0;
                border-bottom: 100px solid red;
                border-right: 100px solid transparent;
                content: "";
            }

            .f:after {
                position: absolute;
                left: 0;
                right: 1px;
                top: 1px;
                bottom: 0;
                border-bottom: 99px solid white;
                border-right: 99px solid transparent;
                content: "";
            }
复制代码

 

x 是 斜线, f 是反斜线。

图:

 

附:CSS 图形:

css3激发想象/css3各种图形 http://www.cnblogs.com/wwcherish/archive/2012/09/18/2690336.html

CSS3机器猫: http://keleyi.com/keleyi/phtml/html5/3.htm

 

方案二

 background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><line x1="0" y1="0" x2="100%" y2="100%" stroke="black" stroke-width="1"/></svg>');

 

 

posted @   NewSea  阅读(33592)  评论(2编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示