<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vifix.cn &#187; CSS</title>
	<atom:link href="http://vifix.cn/blog/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://vifix.cn/blog</link>
	<description>compile the dream, compile tomorrow</description>
	<lastBuildDate>Sat, 04 Feb 2012 03:15:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>利用CSS的Border属性来创造三角形</title>
		<link>http://vifix.cn/blog/%e5%88%a9%e7%94%a8css%e7%9a%84border%e5%b1%9e%e6%80%a7%e6%9d%a5%e5%88%9b%e9%80%a0%e4%b8%89%e8%a7%92%e5%bd%a2.html</link>
		<comments>http://vifix.cn/blog/%e5%88%a9%e7%94%a8css%e7%9a%84border%e5%b1%9e%e6%80%a7%e6%9d%a5%e5%88%9b%e9%80%a0%e4%b8%89%e8%a7%92%e5%bd%a2.html#comments</comments>
		<pubDate>Sun, 29 Jun 2008 03:59:19 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=17</guid>
		<description><![CDATA[guu同学昨日问起是否有实现斜线的CSS样式，当时答曰没有——或者说，IE上没有，支持绘图的Canvas元素是HTML5的东西，还没有在IE中得到支持。 今天突然想起这个问题想到可以利用border形成的那条中间线来模拟这种效果，虽称不上完美，但也似乎是个可以变通的方法。当然，局限性也很大，比如不可能自由旋转，边必须是上下左右的某个固定的方向，不能在div里面放文字。 那么效果可以点击这里 代码（其实已经全部包括在上面的HTML文件中了）： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 [...]]]></description>
			<content:encoded><![CDATA[<p>guu同学昨日问起是否有实现斜线的CSS样式，当时答曰没有——或者说，IE上没有，支持绘图的Canvas元素是HTML5的东西，还没有在IE中得到支持。<br />
今天突然想起这个问题想到可以利用border形成的那条中间线来模拟这种效果，虽称不上完美，但也似乎是个可以变通的方法。当然，局限性也很大，比如不可能自由旋转，边必须是上下左右的某个固定的方向，不能在div里面放文字。</p>
<p><a href="http://vifix.cn/atelier/css_triangle/triangle.html">那么效果可以点击这里</a></p>
<p><span id="more-17"></span></p>
<p>代码（其实已经全部包括在上面的HTML文件中了）：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Triangle Demo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	body{
		margin:0;
		padding:10px 30px;
	}
	.text{
		clear:both;
		font-size:12px;
		line-height:30px;
	}
	.triangle{
		background:#fff;
		width:0px;
		height:0px;
		overflow:hidden;
		float:left;
		margin-left:10px;
	}
	#triangle1{
		border-top:100px solid #fff;
		border-left:200px solid #03f;
		border-bottom:100px solid #fff;
	}
	#triangle2{
		border-top:100px solid #fff;
		border-right:200px solid #06f;
		border-bottom:100px solid #fff;
	}
	#triangle3{
		border-top:200px solid #09f;
		border-left:100px solid #fff;
		border-right:100px solid #fff;
	}
	#triangle4{
		border-bottom:200px solid #0cf;
		border-left:100px solid #fff;
		border-right:100px solid #fff;
	}
	#triangle5{
		border-top:100px solid #c00;
		border-left:100px solid #fff;
		border-bottom:100px solid #0c0;
		border-right:100px solid #fff;
	}
	#triangle6{
		border-top:150px solid #c00;
		border-left:150px solid #0c0;
		border-bottom:50px solid #fff;
		border-right:50px solid #fff;
	}
	#triangle7{
		border-top:100px solid #fff;
		border-left:100px solid #c00;
		border-bottom:100px solid #0c0;
		border-right:100px solid #00c;
	}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		基本形状：
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle1&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle2&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle3&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle4&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		复合形状（为了区分不同的边，用了不同的颜色）：
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle5&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle6&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;triangle7&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;triangle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		通过border的其它组合还可以拼出更多的形状（七巧板-&gt;四巧板？）……嗯，看来可以考虑写个javascript专门绘制三角形了
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/%e5%88%a9%e7%94%a8css%e7%9a%84border%e5%b1%9e%e6%80%a7%e6%9d%a5%e5%88%9b%e9%80%a0%e4%b8%89%e8%a7%92%e5%bd%a2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

