首页 新闻 会员 周边 捐助

关于div的float属性的问题...

0
悬赏园豆:50 [已解决问题] 解决于 2008-08-13 06:30
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <DIV class=cnblogs_code>关于利用float实现一行两个的div...</DIV> <DIV class=cnblogs_code>按照以下代码所写...</DIV> <DIV class=cnblogs_code>但是这样好像也浮动在了父div层上...如图:<IMG height=52 src="http://i.namipan.com/files/b84caedbef68963538eef34a98a929faedb36352ee130000ab75/0/QQ%E6%88%AA%E5%9B%BE%E6%9C%AA%E5%91%BD%E5%90%8D.jpg" width=563 mce_src="http://i.namipan.com/files/b84caedbef68963538eef34a98a929faedb36352ee130000ab75/0/QQ%E6%88%AA%E5%9B%BE%E6%9C%AA%E5%91%BD%E5%90%8D.jpg"></DIV> <DIV class=cnblogs_code>请各位帮忙讲解一下...我是这方面的新人...</DIV> <DIV class=cnblogs_code>&nbsp;</DIV> <DIV class=cnblogs_code> <DIV class=cnblogs_code><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">HTML</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">HEAD</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">test</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="GENERATOR"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Content</SPAN><SPAN style="COLOR: #0000ff">="Microsoft&nbsp;Visual&nbsp;Studio&nbsp;.NET&nbsp;7.1"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="CODE_LANGUAGE"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Content</SPAN><SPAN style="COLOR: #0000ff">="C#"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="vs_defaultClientScript"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;content</SPAN><SPAN style="COLOR: #0000ff">="JavaScript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="vs_targetSchema"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;content</SPAN><SPAN style="COLOR: #0000ff">="http://schemas.microsoft.com/intellisense/ie5"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">HEAD</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">body&nbsp;</SPAN><SPAN style="COLOR: #ff0000">MS_POSITIONING</SPAN><SPAN style="COLOR: #0000ff">="GridLayout"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="Form1"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;method</SPAN><SPAN style="COLOR: #0000ff">="post"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;runat</SPAN><SPAN style="COLOR: #0000ff">="server"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">div&nbsp;</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000ff">="BORDER-RIGHT:blue&nbsp;1px&nbsp;solid;&nbsp;BORDER-TOP:blue&nbsp;1px&nbsp;solid;&nbsp;BORDER-LEFT:blue&nbsp;1px&nbsp;solid;&nbsp;LINE-HEIGHT:30px;&nbsp;BORDER-BOTTOM:blue&nbsp;1px&nbsp;solid;&nbsp;TEXT-ALIGN:left"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">div&nbsp;</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000ff">="BORDER-RIGHT:blue&nbsp;1px&nbsp;solid;&nbsp;BORDER-TOP:blue&nbsp;1px&nbsp;solid;&nbsp;FONT-WEIGHT:bold;&nbsp;FONT-SIZE:14px;&nbsp;FLOAT:left;&nbsp;VERTICAL-ALIGN:middle;&nbsp;OVERFLOW:hidden;&nbsp;BORDER-LEFT:blue&nbsp;1px&nbsp;solid;&nbsp;WIDTH:100px;&nbsp;LINE-HEIGHT:30px;&nbsp;BORDER-BOTTOM:blue&nbsp;1px&nbsp;solid;&nbsp;FONT-STYLE:normal;&nbsp;HEIGHT:30px;&nbsp;FONT-VARIANT:normal"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;abc<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">div</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">div&nbsp;</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000ff">="BORDER-RIGHT:blue&nbsp;1px&nbsp;solid;&nbsp;BORDER-TOP:blue&nbsp;1px&nbsp;solid;&nbsp;FLOAT:right;&nbsp;BORDER-LEFT:blue&nbsp;1px&nbsp;solid;&nbsp;BORDER-BOTTOM:blue&nbsp;1px&nbsp;solid;&nbsp;HEIGHT:30px;&nbsp;TEXT-ALIGN:right"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;abc<BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">div</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">div</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">HTML</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV></DIV>
TimLeaf的主页 TimLeaf | 初学一级 | 园豆:80
提问于:2008-08-12 22:43
< >
分享
最佳答案
0
你在要浮动的两个div后再加一个div,并设置样式为 clear: both,这样就可以了(因为clear:both说明这个div不允许左右有浮动元素,于是就往下跑,撑开了父div),如下: <div style="float:left;..."> abc </div> <div style="float:left;..."> abc </div> <div style="clear:both"></div> 你这种两列的情况,我一般都是两个都float:left
水言木 | 小虾三级 |园豆:586 | 2008-08-13 00:41
其他回答(1)
0
补充:楼主已经在外层加了div,所以只需要在那个float:right的div后面加一行就可以了<div style="clear:both;"></div> 其实没有外层div的情况下使用这一行也可以实现目的,而那个float:right最好还是保留,这样可以保证两端对齐,中间的留白多或少几个像素关系不大,不然两端对齐会受浏览器兼容性的影响,不好搞了 另外有个建议,开发工具最好换换吧,你这个VS2003实在不是做这事的好工具,VS2005/2008都还好,这两个差别不大,不过VS2003就差得远了,无论速度还是功能上都有差距,对标准的支持VS2003根本就没有 再就是对于HTML/CSS,建议花两天的时间大概看一下,一共常用的只有二三十个定义,很容易搞得差不多明白,会对工作效率有很大帮助
丁学 | 园豆:18730 (专家六级) | 2008-08-13 06:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册