欢迎光临
我们一直在努力

怎么用CSS实现三角形标记

这篇文章主要介绍怎么用CSS实现三角形标记,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

  代码如下:

  CssMark.html

  <!DOCTYPEhtml>

  <html>

  <head>

  <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>

  <title></title>

  <linkrel="stylesheet"type="text/css"href="CssMark.css"/>

  </head>

  <body>

  <divclass="TriMarkPre0"></div>

  <br/>

  <divclass="TriMarkPre1"></div>

  <br/>

  <divclass="TriMarkPre2"></div>

  <br/>

  <divclass="TriMark"></div>

  </body>

  </html>

  CssMark.css

  .TriMarkPre0{

  position:static;

  width:100px;

  height:100px;

  border:10pxsolidtransparent;

  border-color:#0058e2;

  }

  .TriMarkPre1{

  position:static;

  width:100px;

  height:100px;

  border:10pxsolidtransparent;

  border-left-color:#0058e2;

  }

  .TriMarkPre2{

  position:static;

  width:0px;

  height:0px;

  border:10pxsolidtransparent;

  border-left-color:#0058e2;

  }

  .TriMark{

  position:static;

  width:0px;

  height:0px;

  border:5pxsolidtransparent;

  border-left-color:#0058e2;

  }

  代码详解

  创建流程1:

  下面的代码是绘制100×100像素区域的外框的代码。这是一般代码。

  执行结果图像顶部的方框对应于该代码。

  <divclass="TriMarkPre0"></div>

  .TriMarkPre0{

  position:static;

  width:100px;

  height:100px;

  border:10pxsolidtransparent;

  border-color:#0058e2;

  }

  创建过程2:

  使用下面的代码,仅绘制区域框架的左侧。如果您绘制左侧,您可以看到拐角部分是对角切割的。(当绘制4个边时,只绘制一半以使每条线不重叠。)

  此代码对应于将执行结果图像的第二个梯形向侧面的代码。

  <divclass="TriMarkPre1"></div>

  .TriMarkPre1{

  position:static;

  width:100px;

  height:100px;

  border:10pxsolidtransparent;

  border-left-color:#0058e2;

  }

  完成:

  可以使用以下代码绘制三角形标记。

  通过减小前一行左侧代码的高度,行之间的部分将消失,它将显示为三角形标记。

  执行结果图像的第三个图对应于该代码。

  <divclass="TriMarkPre2"></div>

  .TriMarkPre2{

  position:static;

  width:0px;

  height:0px;

  border:10pxsolidtransparent;

  border-left-color:#0058e2;

  }

  您可以通过减小线的边框宽度来更改三角形标记的大小。

  执行结果图像的第四个图对应于该代码。

  <divclass="TriMark"></div>

  .TriMark{

  position:static;

  width:0px;

  height:0px;

  border:5pxsolidtransparent;

  border-left-color:#0058e2;

  }

以上是“怎么用CSS实现三角形标记”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注云搜网行业资讯频道!

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。