网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网页制作 > CSS
网页制作:Dreamweaver教程,FrontPages教程,Javascript教程,HTML教程,CSS教程,心得技巧,DHTML教程,网页特效,Discuz!论坛
本月文章推荐
.CSS+js放大镜.
.CSS属性与JavaScript编码对照表.
.Css Reset(復位)整理.
.CSS特点及加入网页的四种方法.
.实现页面图片阴影特效.
.实例详解CSS网页布局原理.
.Css Reset(复位)整理.
.CSS中的Position属性.
.精通 CSS 滤镜(四).
.CSS属性中Display与Visibility的.
.css的引用文件方式.
.CSS初学教程 如何修改blog中的CSS.
.CSS初级入门:样式的多次声明.
.CSS条状图表形式的实现方法.
.IE的IF条件注释使用备忘.
.用CSS样式固定表格宽度.
.用CSS等比例缩放图片.
.css用expression来区分只读文本框.
.纯CSS实现的可包含html的title提.
.CSS创建圆角框.

CSS+DIV:让文本字符环绕在你的图片周围

发表日期:2006-6-13


  看到上面的效果,你也许以为这是一张带文字的图片而已;呵呵,用你的鼠标去选取文字看看,发现了吧,这完完全全是一张图片和文字的组合,下面我就来介绍它是怎么做的。

  先看看代码:

   以下是引用片段:
<div id="info">
<h2>TRACKING YOUR IMAGES</h2>
<div id="holdit">
<img src="/imagelist/06/24/4fnpgj5042e6.jpg" alt="Winnie the pooh" title="Winnie the pooh" />
<em class="a420"></em>
<em class="a430"></em>
<em class="a400"></em>
<em class="a370"></em>
<em class="a340"></em>
<em class="a300"></em>
<em class="a270"></em>
<em class="a250"></em>
<em class="a240"></em>
<em class="a230"></em>
<em class="a230"></em>
<em class="a340"></em>
<em class="a340"></em>
<em class="a360"></em>
<em class="a540"></em>
<em class="a540"></em>
<em class="a540"></em>
<em class="a550"></em>
<em class="a550"></em>
<em class="a550"></em>
<em class="a550"></em>
<em class="a550"></em>
<em class="a550"></em>
<em class="a540"></em>
<em class="a460"></em>
<em class="a490"></em>
<em class="a500"></em>
<em class="a500"></em>
<p>"I shall have to wait until I catch up with it," said Winnie-the-Pooh. "Now, look there." He pointed to the ground in front of him. "What do you see there?"<br />
"Tracks," said Piglet. "Paw-marks." He gave a little squeak of excitement. "Oh, Pooh! Do you think it's a--a--a Woozle?"<br />
"It may be," said Pooh. "Sometimes it is, and sometimes it isn't. You never can tell with paw- marks."<br />
With these few words he went on tracking, and Piglet, after watching him for a minute or two, ran after him. Winnie-the-Pooh had come to a sudden stop, and was bending over the tracks in a puzzled sort of way.<br />
"What's the matter?" asked Piglet.<br />
"It's a very funny thing," said Bear, "but there seem to be two animals now. This--whatever-it-was--has been joined by another--whatever-it-is--
and the two of them are now proceeding in company. Would you mind coming with me, Piglet, in case they turn out to be Hostile Animals?"<br />
Piglet scratched his ear in a nice sort of way, and said that he had nothing to do until Friday, and would be delighted to come, in case it really was a Woozle.<br />
"You mean, in case it really is two Woozles," said Winnie-the-Pooh, and Piglet said that anyhow he had nothing to do until Friday. So off they went together.</p>
</div>
</div>


   以下是引用片段:
#info h3{ text-align:center;
}
#holdit {width:700px; position:relative; margin:3em auto; padding:10px; border:1px solid #ddd;}
#holdit img {position:absolute; z-index:1; top:10px; left:10px; }
#holdit p { margin:0px; position:relative; z-index:10; line-height:18px; text-align:justify; font-size:10px; font-family:verdana, arial, sans-serif}
#holdit em {display:block; float:left; height:18px; clear:left; overflow:hidden; }
.a230 {width:230px;}
.a240 {width:240px;}
.a250 {width:250px;}
.a270 {width:270px;}
.a300 {width:300px;}
.a340 {width:340px;}
.a360 {width:360px;}
.a370 {width:370px;}
.a400 {width:400px;}
.a420 {width:420px;}
.a430 {width:430px;}
.a460 {width:460px;}
.a490 {width:490px;}
.a500 {width:500px;}
.a540 {width:540px;}
.a550 {width:550px;}


  接着我们来分析一下红色加亮的部分:

  首先将包容对象#holdit设置成相对定位(确保等下的img绝对定位以它左上角为原点)

  接着把#holdit里面的img设成绝对定位且z-index高度为1,这样img就脱离文档流了

  将em标签设置左浮动,高度和p的ling-height要一样,再根据图片的图案分别设置每个em的宽度(记得要用clear来清除浮动)

  最后把P设置成相对定位且z-index高度设置大于img的数值

  其实我们也可以直接将图片作为为#holdit的背景,这样就不需要专门为img来设置CSS了

上一篇:用相对定位和负向移动完成图片象框阴影 人气:10635
下一篇:用CSS做滑动效果的图片画廊 人气:12855
浏览全部CSS的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐