<?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>相信明天会更好 &#187; 布局</title>
	<atom:link href="http://www.sunnyweiwei2008.cn/tag/%e5%b8%83%e5%b1%80/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sunnyweiwei2008.cn</link>
	<description>Tomorrow will be better</description>
	<lastBuildDate>Thu, 25 Feb 2010 08:20:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>用css控制背景图片</title>
		<link>http://www.sunnyweiwei2008.cn/2008/09/%e7%94%a8css%e7%a9%ba%e5%80%bc%e8%83%8c%e6%99%af%e5%9b%be%e7%89%87.html</link>
		<comments>http://www.sunnyweiwei2008.cn/2008/09/%e7%94%a8css%e7%a9%ba%e5%80%bc%e8%83%8c%e6%99%af%e5%9b%be%e7%89%87.html#comments</comments>
		<pubDate>Sun, 07 Sep 2008 12:15:16 +0000</pubDate>
		<dc:creator>sunny</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[bacjground]]></category>
		<category><![CDATA[布局]]></category>

		<guid isPermaLink="false">http://www.sunnyweiwei.cn/?p=44</guid>
		<description><![CDATA[css中用background-image属性给元素的背景添加了图片。例如要把图片作为网页背景可以给body标签创建一个样式： CSS语言: body { background-image:url(images/bg.gif); } 其中url中的值可以用引号引住也可以不用。 关于背景图片的重复可以用如下属性来控制：background-repeat，属性值有： no-repeat：不重复，只显示图片一次。用于设计网站的logo。 repeat-x：在x轴上平铺。可以用来设置图片横幅。 repeat-y：在y轴上平铺，可以用它来添加一个工具条。 定位背景图片可以用如下属性：background-position：center  center、center  top、center  bottom、top  right、bottom  right、left  top 、left  bottom等等，也可以用精确的值来定位例如background-position：5px  8px，属性值也可以是百分比。 背景图片的固定用如下属性：background-attachment：scroll/fixed 。前者的意思是背景图片随着网页的内容一起滚动，后者的意思是把图片保留在背景中的固定位置上如logo。 当然你为了空值背景图片没有必要一遍一遍的详细输入各个属性，一个简单的做法是： background：#FFF url（../image/logo.gif）fixed center center  no-repeat; 给无序列表使用图片&#8211;以往无需列表的项目符号是一个黑点。如果想要用图片代替那么首先你要隐藏正常显示在列表项目旁边的项目符号。像这样： .sidebar li { list-style:none; } 现在就可以添加图片做项目符号了： background-image:url(images/flower.gif); background-repeat:no-repeat; 添加完毕以后，你就可以看到新的项目符号了。可能会有一些错位，比如项目符号与文字重叠或者项目符号偏上/下等等这些在稍微调试一下即可。 background-position:0px  2px;//将项目符号下移 padding-left:18px;//将内容与项目符号间的空间增大，来显示图片 margin-bottom:6px;//将两个无序列表之间留点空隙 给工具条添加一个圆角的背景图片（该图片高度并不是很高）： 注意事项： 工具条此时不要用border属性，否则显示不出圆角。 为了是工具条的内容与背景中底边的花朵不重叠可以设置：padding-bottom：75px来加大距离。 要是工具条的宽度与背景图片的宽度相同，不要padding-left、padding-right属性。 要设置图片的位置为center  bottom这样才能保证工具条的下方是圆角。]]></description>
			<content:encoded><![CDATA[<p>css中用background-image属性给元素的背景添加了图片。例如要把图片作为网页背景可以给body标签创建一个样式：</p>
<div style="background: #fdfdfd none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="text-decoration: underline;">CSS语言</span>:</div>
<div class="source" style="font-family: "><span style="font-weight: bold; color: #000080;">body</span><br />
{<br />
<span style="font-weight: bold; color: #000080;">background-image</span>:<span style="color: #0000ff;">url(images/bg.gif)</span>;<br />
}</div>
<p>其中url中的值可以用引号引住也可以不用。</p>
<p>关于背景图片的重复可以用如下属性来控制：background-repeat，属性值有：</p>
<ul>
<li>no-repeat：不重复，只显示图片一次。用于设计网站的logo。</li>
<li>repeat-x：在x轴上平铺。可以用来设置图片横幅。</li>
<li>repeat-y：在y轴上平铺，可以用它来添加一个工具条。<span id="more-44"></span></li>
</ul>
<p>定位背景图片可以用如下属性：background-position：center  center、center  top、center  bottom、top  right、bottom  right、left  top 、left  bottom等等，也可以用精确的值来定位例如background-position：5px  8px，属性值也可以是百分比。</p>
<p>背景图片的固定用如下属性：background-attachment：scroll/fixed 。前者的意思是背景图片随着网页的内容一起滚动，后者的意思是把图片保留在背景中的固定位置上如logo。</p>
<p>当然你为了空值背景图片没有必要一遍一遍的详细输入各个属性，一个简单的做法是：</p>
<p>background：#FFF url（../image/logo.gif）fixed center center  no-repeat;</p>
<p>给无序列表使用图片&#8211;以往无需列表的项目符号是一个黑点。如果想要用图片代替那么首先你要隐藏正常显示在列表项目旁边的项目符号。像这样：</p>
<div class="source" style="font-family: ">.sidebar <span style="font-weight: bold; color: #000080;">li</span><br />
{<br />
list-style:<span style="font-weight: bold; color: #000080;">none</span>;<br />
}</div>
<p>现在就可以添加图片做项目符号了：</p>
<div class="source" style="font-family: "><span style="font-weight: bold; color: #000080;">background-image</span>:url(<span style="font-weight: bold; color: #000080;">images</span>/<span style="font-weight: bold; color: #000080;">flower</span>.gif);<br />
<span style="font-weight: bold; color: #000080;">background-repeat</span><span style="color: #a61717;">:</span><span style="font-weight: bold; color: #000080;">no-repeat</span>;</div>
<p>添加完毕以后，你就可以看到新的项目符号了。可能会有一些错位，比如项目符号与文字重叠或者项目符号偏上/下等等这些在稍微调试一下即可。</p>
<div class="source" style="font-family: "><span style="font-weight: bold; color: #000080;">background-position</span>:0px  <span style="font-weight: bold; color: #000080;">2px</span>;//将项目符号下移<br />
<span style="font-weight: bold; color: #000080;">padding-left</span>:18px;//将内容与项目符号间的空间增大，来显示图片<br />
<span style="font-weight: bold; color: #000080;">margin-bottom</span>:6px;//将两个无序列表之间留点空隙</div>
<div class="source" style="font-family: ">给工具条添加一个圆角的背景图片（该图片高度并不是很高）：</div>
<div class="source" style="font-family: ">注意事项：</div>
<div class="source" style="font-family: ">
<ul>
<li>工具条此时不要用border属性，否则显示不出圆角。</li>
<li>为了是工具条的内容与背景中底边的花朵不重叠可以设置：padding-bottom：75px来加大距离。</li>
<li>要是工具条的宽度与背景图片的宽度相同，不要padding-left、padding-right属性。</li>
<li>要设置图片的位置为center  bottom这样才能保证工具条的下方是圆角。</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunnyweiwei2008.cn/2008/09/%e7%94%a8css%e7%a9%ba%e5%80%bc%e8%83%8c%e6%99%af%e5%9b%be%e7%89%87.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

