建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > div+css > 用纯CSS制作带三角尖尖的效果

用纯CSS制作带三角尖尖的效果

时间:2015-01-29 09:42:54  来源:免费模板网 作者:风雪 阅读次数 tags用纯CSS制作带三角的边框

    今天学习的是做成下图这个效果

我们知道 html 中有一些特殊的字符,具体的可以去了解下HTML特殊字符大全。通过特殊字符,利用css中的margin或者position方法完全可以实现下图的效果。

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>字符制作三角边框</title>
    <style type="text/css">
    *{margin:0;padding:0;}
    body{font-family:SimSun;}
    h1{text-align:center;}
    .demo1{width:300px;margin:20px auto;border:1px solid red;height:100px;}
    .demo1 em,.demo1 span{display:block;width:30px;height:16px;font-size:30px;overflow:hidden;_position:relative;margin-left:10px;}
    .demo1 em{margin-top:-16px;color:red;font-style:normal;}
    .demo1 span{margin-top:-14px;color:white;}
   
    .demo2{width:300px;border:1px solid #F00;height:100px;position:relative;margin-left:auto;margin-right:auto;}
    .demo2 em,.demo2 span{font-style:normal;font-size:30px;position:absolute;left:-16px;top:40px;color:red;}
    .demo2 span{left:-14px;color:white;}
    </style>
</head>
<body>
    <h1>demo1 是用 margin 方法</h1>
    <div class="demo1">
        <em>&#9670;</em>
        <span>&#9670;</span>
    </div>
    <h1>demo2 是用 position 方法</h1>
    <div class="demo2">
        <em>&#9670;</em>
        <span>&#9670;</span>
    </div>
</body>
</html>

本文地址:https://www.freemoban.com/bjrm/2015/0129/319.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!