CSS制作三角边框

<!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:100px;

margin:20px auto;

border:1px solid red;

height:100px;

}

.demo1 em,.demo1 span

{

display:block;

width:30px;

height:15px;

font-size:30px;

overflow:hidden;

_position:relative;

margin-left:20px;

}

.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;

}

/*

对话气泡

用法:使用.speech-bubble和.speech-bubble-DIRECTION类

<div class="speech-bubble speech-bubble-top">Hi there</div>

*/

.speech-bubble {

position: relative;

background-color: #292929;

width: 200px;

height: 150px;

line-height: 150px;

color: white;

border-radius: 10px;

font-family: sans-serif;

}*/

.speech-bubble:after {

content: ‘‘;

position: absolute;

width: 0;

height: 0;

border: 15px solid

}

.speech-bubble-top:after {

border-bottom-color:#0000FF;

left: 50%;

bottom: 100%;

margin-left: -15px;

}

.speech-bubble-right:after {

border-left-color: #292929;

left: 100%;

top: 50%;

margin-top: -15px;

}

.speech-bubble-bottom:after {

border-top-color: #292929

top: 100%;

left: 50%;

margin-left: -15px;

}

.speech-bubble-left:after {

border-right-color: #292929;

top: 50%;

right: 100%;

margin-top: -15px;

}

</style>

</head>

<body>

<h1>demo1 是用 margin 方法</h1>

<div class="demo1">

<em>◆</em>

<span>◆</span>

</div>

<h1>demo2 是用 position 方法</h1>

<div class="demo2">

<em>◆</em>

<span>◆</span>

</div>

<div class="speech-bubble speech-bubble-top">

</div>

<div class="speech-bubble speech-bubble-bottom">

箭头在底部

</div>

<div class="speech-bubble speech-bubble-left">

箭头在左侧

</div>

<br/>

<div class="speech-bubble speech-bubble-right">

箭头在右侧

</div>

</body>

</html>

时间: 2024-08-29 14:38:03

CSS制作三角边框的相关文章

纯CSS制作三角(转)

原原文地址:http://www.w3cplus.com/code/303.html 原文地址:http://blog.csdn.net/dyllove98/article/details/8967012 以前写过一篇纯CSS制作带三角的边框,那篇文章是用HTML特殊字符来制作三角的,今天介绍下,如何用 border 来制作三角. html 代码如下: <div class="arrow-up"></div> <div class="arrow-

用css 制作三角

html代码: <div class="div"></div> css代码: .div{ border-top:40px solid #ff0077; border-left:40px solid #004444; border-bottom:40px solid #999999; border-right:40px solid #333333; height: 0px; width: 0px; } 效果: 现在一个一个分解出来 html代码: <div

补充:css制作三角

梯形图案看下面这段样式: .test{width:10px; height:10px; border:10px solid; border-color:#ff3300 #0000ff #339966 #00ff00;} 当某个div应用了上面这个样式后,结果会如何?见下图(截自Firefox3.5,IE浏览器有细节上的差异): 更进一步 – 部分边框透明现在,设想一下,如果我们现在只保留一个一个上边框,其余边框均transparent透明(或与背景色同色),那么是不是就只显示一个上面红色的边框了

追求极致--纯css制作三角、圆形按钮,兼容ie6

参考了天猫.微博等网站的做法,用纯html和css实现,效果还是不错的.以下是成果,兼容主流浏览器,包括ie6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> &l

纯css制作带三角(兼容所有浏览器)

如何用 border 来制作三角. html 代码如下: 代码如下: <div class="arrow-up"></div> <div class="arrow-down"></div> <div class="arrow-left"></div> <div class="arrow-right"></div> css 代码如下:

纯CSS制作的三角箭头

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>纯CSS制作的三角箭头丨kiddy<

纯CSS小三角制作

无关的知识点 ① background-clip 属性规定背景的绘制区域. 1.padding-box:从padding区域(不含padding)开始向外裁剪背景. 2.border-box:从border区域(不含border)开始向外裁剪背景. 3.content-box:从content区域开始向外裁剪背景. 4.text:从前景内容的形状(比如文字)作为裁剪区域向外裁剪,如此即可实现使用背景作为填充色之类的遮罩效果. ② clip auto:对象无剪切rect(<number>|aut

css制作小三角

视觉稿中经常有些小三角,如下图.每次用图片做太不方便了,我们看看用css实现的效果(支持ie6,7哦) <style> /*border实现三角*/ /*箭头向上*/ .arrow-top{ width : 0; height : 0; font-size : 0; line-height : 0; border-left: 5px dashed transparent; border-right: 5px dashed transparent; border-bottom: 5px soli

css挤带边框的三角

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> .triangle{ width:100px;