html – Float Left 100%height div – div之间的差距

前端之家收集整理的这篇文章主要介绍了html – Float Left 100%height div – div之间的差距前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
标记
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Zuhaib.test" %>
  2. <!-- Put IE into quirks mode -->
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  6. <head runat="server">
  7. <title></title>
  8. <link href="css/general.css" rel="stylesheet" type="text/css" />
  9. <link href="css/outbound.css" rel="stylesheet" type="text/css" />
  10. </head>
  11. <body>
  12. <form id="form1" runat="server" class="wrapper">
  13. <asp:ScriptManager ID="ScriptManager1" runat="server">
  14. </asp:ScriptManager>
  15. <div id="left">
  16. </div>
  17. <div id="right">
  18. </div>
  19. </form>
  20. </body>
  21. </html>

CSS

  1. html,body
  2. {
  3. margin:0;
  4. padding:0;
  5. border:0;
  6. overflow:hidden;
  7. width:100%;
  8. height:100%;
  9. }
  10. * html body
  11. {
  12. height:100%;
  13. width:100%;
  14. }
  15. *{
  16. margin:0;
  17. padding:0;
  18. }
  19. .wrapper
  20. {
  21. position:fixed;
  22. top:0px;
  23. bottom:0px;
  24. left:0px;
  25. right:0px;
  26. height:100%;
  27. width:100%;
  28. }
  29. * html .wrapper
  30. {
  31. width:100%;
  32. height:100%;
  33. }
  34. #left{
  35. float:left;
  36. height:100%;
  37. width:100px;
  38. overflow:hidden;
  39. background-color:Blue;
  40. }
  41. * html #left{
  42. height:100%;
  43. width:100px;
  44. }
  45. #right{
  46. margin-left:100px;
  47. height:100%;
  48. background-color:Red;
  49. }
  50. * html #right{
  51. height:100%;
  52. }

导致IE&& FF
Resutls in IE & FF http://img139.imageshack.us/img139/9871/ie3pxgapnl4.jpg
IE 6& S的结果相同. 7.如何消除div之间的差距?

UDATE
我有两个div,每个都有100%的高度.左边div是一个固定宽度的浮动div.即使在向右侧div提供正确的边距之后,两个div之间仍然存在间隙(3px).在firefox中它正确呈现.

我使用quirk模式的原因是能够为div获得100%的高度

这个差距可以消除吗?或者有更好的方法来使用纯css进行两列100%高度布局?

解决方法

如前所述,您的代码充满了黑客攻击.请删除特别不必要的定义.如果浏览器不支持级联样式表,则无论如何它都不支持CSS.

话虽如此,为什么不使用position:absolute;为#right?

如在

  1. #right{
  2. position: absolute;
  3. left: 100px;
  4. padding-left: -100px;
  5. width: 100%;
  6. ...
  7. }

猜你在找的HTML相关文章