首页 > web前端 > css教程 > 正文

css实现尖角div

高洛峰
发布: 2016-11-24 10:33:35
原创
2333人浏览过

尖角在上面

效果图:

纯CSS实现多彩三角形有序变化特效动画时尚背景墙
纯CSS实现多彩三角形有序变化特效动画时尚背景墙

纯CSS实现多彩三角形有序变化特效动画时尚背景墙。

纯CSS实现多彩三角形有序变化特效动画时尚背景墙 225
查看详情 纯CSS实现多彩三角形有序变化特效动画时尚背景墙

4ad0bf1178ce3ef3a05e5cfae3c28258.jpg

代码:


[html]
<html> 
<head> 
<title>尖角div</title> 
<style type="text/css"> 
#top 

  width:400px; 
  height:250px; 
  border:3px solid;   /* 边框宽度为3px */ 
  position:relative; 

.sp1,.sp2 

  display:block; 
  height:0px; 
  width:0px; 
  position:absolute; 
  font-size:0; 
  line-height:0; 

.sp1 

  top:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */ 
  left:40px;   /* 它来确定尖角的位置 */ 
  border-top:0px; 
  border-bottom:6px solid black;  /* 注意颜色的变化 */ 
  border-right:6px solid white; 
  border-left:6px solid white; 

.sp2 

  top:6px;  /* 是自身边框宽度的2倍 */ 
  left:-3px; /* 是自身边框宽度的-1倍  */ 
  border-top:0px; 
  border-bottom:3px solid white; 
  border-right:3px solid black; 
  border-left:3px solid black; 

 
</style> 
</head> 
 
<body> 
<div id="top"> 
<span class="sp1"> 
<span class="sp2"></span> 
</span> 
</div> 
</body> 
 
</html> 

立即学习前端免费学习笔记(深入)”;

<html>
<head>
<title>尖角div</title>
<style type="text/css">
#top
{
  width:400px;
  height:250px;
  border:3px solid;   /* 边框宽度为3px */
  position:relative;
}
.sp1,.sp2
{
  display:block;
  height:0px;
  width:0px;
  position:absolute;
  font-size:0;
  line-height:0;
}
.sp1
{
  top:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */
  left:40px;   /* 它来确定尖角的位置 */
  border-top:0px;
  border-bottom:6px solid black;  /* 注意颜色的变化 */
  border-right:6px solid white;
  border-left:6px solid white;
}
.sp2
{
  top:6px;  /* 是自身边框宽度的2倍 */
  left:-3px; /* 是自身边框宽度的-1倍  */
  border-top:0px;
  border-bottom:3px solid white;
  border-right:3px solid black;
  border-left:3px solid black;
}

</style>
</head>

<body>
<div id="top">
<span class="sp1">
<span class="sp2"></span>
</span>
</div>
</body>

</html>
尖角在下面

效果图:

 


代码:


[html] 
<html> 
<head> 
<title>尖角div</title> 
<style type="text/css"> 
#bottom 

  width:400px; 
  height:250px; 
  border:3px solid;   /* 边框宽度为3px */ 
  position:relative; 

.sp1,.sp2 

  display:block; 
  height:0px; 
  width:0px; 
  position:absolute; 
  font-size:0; 
  line-height:0; 

.sp1 

  bottom:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */ 
  left:40px;   /* 它来确定尖角的位置 */ 
  border-bottom:0px; 
  border-top:6px solid black;  /* 注意颜色的变化 */ 
  border-right:6px solid white; 
  border-left:6px solid white; 

.sp2 

  bottom:6px;  /* 是自身边框宽度的2倍 */ 
  left:-3px; /* 是自身边框宽度的-1倍  */ 
  border-bottom:0px; 
  border-top:3px solid white; 
  border-right:3px solid black; 
  border-left:3px solid black; 

 
</style> 
</head> 
 
<body> 
<div id="bottom"> 
<span class="sp1"> 
<span class="sp2"></span> 
</span> 
</div> 
</body> 
 
</html> 

<html>
<head>
<title>尖角div</title>
<style type="text/css">
#bottom
{
  width:400px;
  height:250px;
  border:3px solid;   /* 边框宽度为3px */
  position:relative;
}
.sp1,.sp2
{
  display:block;
  height:0px;
  width:0px;
  position:absolute;
  font-size:0;
  line-height:0;
}
.sp1
{
  bottom:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */
  left:40px;   /* 它来确定尖角的位置 */
  border-bottom:0px;
  border-top:6px solid black;  /* 注意颜色的变化 */
  border-right:6px solid white;
  border-left:6px solid white;
}
.sp2
{
  bottom:6px;  /* 是自身边框宽度的2倍 */
  left:-3px; /* 是自身边框宽度的-1倍  */
  border-bottom:0px;
  border-top:3px solid white;
  border-right:3px solid black;
  border-left:3px solid black;
}

</style>
</head>

<body>
<div id="bottom">
<span class="sp1">
<span class="sp2"></span>
</span>
</div>
</body>

</html>
尖角在左边

效果图:

4ad0bf1178ce3ef3a05e5cfae3c28258.jpg

代码:


[html]
<html> 
<head> 
<title>尖角div</title> 
<style type="text/css"> 
#left 

  width:400px; 
  height:250px; 
  border:3px solid;   /* 边框宽度为3px */ 
  position:relative; 

.sp1,.sp2 

  display:block; 
  height:0px; 
  width:0px; 
  position:absolute; 
  font-size:0; 
  line-height:0; 

.sp1 

  left:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */ 
  top:40px;   /* 它来确定尖角的位置 */ 
  border-left:0px; 
  border-top:6px solid white;  /* 注意颜色的变化 */ 
  border-right:6px solid black; 
  border-bottom:6px solid white; 

.sp2 

  left:6px;  /* 是自身边框宽度的2倍 */ 
  top:-3px; /* 是自身边框宽度的-1倍  */ 
  border-left:0px; 
  border-top:3px solid black; 
  border-right:3px solid white; 
  border-bottom:3px solid black; 

 
</style> 
</head> 
 
<body> 
<div id="left"> 
<span class="sp1"> 
<span class="sp2"></span> 
</span> 
</div> 
</body> 
 
</html> 

<html>
<head>
<title>尖角div</title>
<style type="text/css">
#left
{
  width:400px;
  height:250px;
  border:3px solid;   /* 边框宽度为3px */
  position:relative;
}
.sp1,.sp2
{
  display:block;
  height:0px;
  width:0px;
  position:absolute;
  font-size:0;
  line-height:0;
}
.sp1
{
  left:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */
  top:40px;   /* 它来确定尖角的位置 */
  border-left:0px;
  border-top:6px solid white;  /* 注意颜色的变化 */
  border-right:6px solid black;
  border-bottom:6px solid white;
}
.sp2
{
  left:6px;  /* 是自身边框宽度的2倍 */
  top:-3px; /* 是自身边框宽度的-1倍  */
  border-left:0px;
  border-top:3px solid black;
  border-right:3px solid white;
  border-bottom:3px solid black;
}

</style>
</head>

<body>
<div id="left">
<span class="sp1">
<span class="sp2"></span>
</span>
</div>
</body>

</html>
尖角在右边

效果图:

4ad0bf1178ce3ef3a05e5cfae3c28258.jpg

代码:


[html] 
<html> 
<head> 
<title>尖角div</title> 
<style type="text/css"> 
#right 

  width:400px; 
  height:250px; 
  border:3px solid;   /* 边框宽度为3px */ 
  position:relative; 

.sp1,.sp2 

  display:block; 
  height:0px; 
  width:0px; 
  position:absolute; 
  font-size:0; 
  line-height:0; 

.sp1 

  right:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */ 
  top:40px;   /* 它来确定尖角的位置 */ 
  border-right:0px; 
  border-top:6px solid white;  /* 注意颜色的变化 */ 
  border-bottom:6px solid white; 
  border-left:6px solid black; 

.sp2 

  right:6px;  /* 是自身边框宽度的2倍 */ 
  top:-3px; /* 是自身边框宽度的-1倍  */ 
  border-right:0px; 
  border-top:3px solid black; 
  border-bottom:3px solid black; 
  border-left:3px solid white; 

 
</style> 
</head> 
 
<body> 
<div id="right"> 
<span class="sp1"> 
<span class="sp2"></span> 
</span> 
</div> 
</body> 
 
</html> 

<html>
<head>
<title>尖角div</title>
<style type="text/css">
#right
{
  width:400px;
  height:250px;
  border:3px solid;   /* 边框宽度为3px */
  position:relative;
}
.sp1,.sp2
{
  display:block;
  height:0px;
  width:0px;
  position:absolute;
  font-size:0;
  line-height:0;
}
.sp1
{
  right:-9px;    /* 它的绝对值加上span的边框宽度等于div边框宽度的5倍 */
  top:40px;   /* 它来确定尖角的位置 */
  border-right:0px;
  border-top:6px solid white;  /* 注意颜色的变化 */
  border-bottom:6px solid white;
  border-left:6px solid black;
}
.sp2
{
  right:6px;  /* 是自身边框宽度的2倍 */
  top:-3px; /* 是自身边框宽度的-1倍  */
  border-right:0px;
  border-top:3px solid black;
  border-bottom:3px solid black;
  border-left:3px solid white;
}

</style>
</head>

<body>
<div id="right">
<span class="sp1">
<span class="sp2"></span>
</span>
</div>
</body>

</html>


《完》

相关标签:
css
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号