CSS三角形效果的实现及在布局的运用是怎样
发布时间:2023-07-03 11:22:34 所属栏目:语言 来源:
导读:今天我们来学习关于“CSS三角形效果的实现及在布局的应用是怎样”的内容,下文有详解方法和实例,内容详细,逻辑清晰,有需要的朋友可以参考,希望大家阅读完这篇文章后能有所收获,那么下面就一起来了解一
今天我们来学习关于“CSS三角形效果的实现及在布局的应用是怎样”的内容,下文有详解方法和实例,内容详细,逻辑清晰,有需要的朋友可以参考,希望大家阅读完这篇文章后能有所收获,那么下面就一起来了解一下吧。 css三角强化 上期的css三角是等腰的,有是我们需要像下面这中的直角,该怎么做呢? 接下来我一步步教你做: 在上期做法基础上做改动就行 只需要把上期这个盒子左边框和下边框宽度设为0,上边框加大宽度就行。 .demo1{ width:0; height: 0; line-height: 0; font-size: 0; border-top:20px solid red ; border-right:10px solid green ; border-bottom:0px solid blue ; border-left:0px solid purple ; } 正好得到两个方向的直角三角形,将其中一个变透明就行。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .demo1{ width:0; height: 0; line-height: 0; font-size: 0; border-top:20px solid transparent ; border-right:10px solid green ; border-bottom:0px solid blue ; border-left:0px solid purple ; } </style> </head> <body> <div class="demo1"> </div> </body> </html> 案例 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .demo{ width: 160px; height: 24px; line-height: 24px; /* 让文本垂直居中 */ border: 1px solid red; margin: 50px auto; } .demo1{ position: relative; float: left; /* span是行内元素,浮动之后可设置宽高*/ width: 90px; height: 100%; background-color: red; text-align: center; color: #fff; font-weight: 700; margin-right: 8px; } .demo1 i{ position: absolute; right: 0; top: 0; width: 0; height: 0; border-color: transparent #fff transparent transparent; border-style: solid; border-width: 24px 10px 0 0; } .demo2{ font-size: 12px; color: gray; text-decoration: line-through; } </style> </head> <body> <div class="demo"> <span class="demo1"> ¥1500 <i></i> </span> <span class="demo2">¥1999</span> </div> </body> </html> (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐