1. 论坛系统升级为Xenforo,欢迎大家测试!
    Dismiss Notice

原创:(小发现)DIV一个非常细小的问题。

Discussion in '前端开发' started by shangjay, Mar 1, 2006.

  1. shangjay

    shangjay New Member

    Joined:
    Jan 13, 2006
    Messages:
    3,530
    Likes Received:
    15
    <div><img src="logo.gif"/></div>


    <div><img src="logo.gif"/>
    </div>


    代码是一样的。 但是出来的效果不一样。 问题在于 后者的 </div>换了行,换行之后 图片在框架的高度会上升大约2。
    而前者,图片和框架是紧密结合在一起的。

    这个问题,郁闷了我好半天。一直找解决的CSS,怎么都不行。

    不知道是改在 BODY里 定义好呢还是怎么办!
    高手给个好的解决办法!
     
  2. Ulysses

    Ulysses New Member

    Joined:
    Feb 5, 2006
    Messages:
    10,018
    Likes Received:
    16
    不同浏览器下对于 DOM 的解析不同,IE 下可能认为换行符也是一个节点。

    这个节点类似之前你的一个问题中:图片后紧跟文字,div 边框无法和图片边框紧贴——这个可以通过图片的 align 属性来尝试解决。
     
  3. Zooyiy

    Zooyiy New Member

    Joined:
    Jan 12, 2006
    Messages:
    8
    Likes Received:
    1
    #div img {
    vertical-align: bottom;
    }

    这样就可以了!
     
    小叶 likes this.
  4. Ulysses

    Ulysses New Member

    Joined:
    Feb 5, 2006
    Messages:
    10,018
    Likes Received:
    16
    Zooyiy 的方法正确,受教了。
     
  5. 流氓兔

    流氓兔 New Member

    Joined:
    Sep 27, 2005
    Messages:
    905
    Likes Received:
    3
    呵呵跟着你们屁股学 我也正在学 重构
     
  6. 西子宜

    西子宜 Well-Known Member

    Joined:
    Sep 5, 2005
    Messages:
    15,739
    Likes Received:
    62
  7. 飞天宝

    飞天宝 New Member

    Joined:
    Mar 4, 2006
    Messages:
    12
    Likes Received:
    0
    哦~受教了。以后多来看看
     
  8. laogui

    laogui Administrator
    Staff Member

    Joined:
    Aug 30, 2005
    Messages:
    15,216
    Likes Received:
    35
    IE太垃圾了,这个问题在其他浏览器下没有
     
  9. pjuser

    pjuser New Member

    Joined:
    Mar 5, 2006
    Messages:
    11
    Likes Received:
    0
    这个东西有时候是觉得出错的地方莫名其妙,要多转转了
     
  10. pjuser

    pjuser New Member

    Joined:
    Mar 5, 2006
    Messages:
    11
    Likes Received:
    0
    对了,大家有没有什么好些的手册或者教程啊,最好是实例结合直观一些的,谢谢了
     
  11. comic

    comic New Member

    Joined:
    Mar 5, 2006
    Messages:
    302
    Likes Received:
    2
    偶也是菜鸟```继续学习````
     
  12. jeminy

    jeminy Member

    Joined:
    Sep 27, 2005
    Messages:
    975
    Likes Received:
    13
    谢谢分享~
     
  13. redfox

    redfox New Member

    Joined:
    Mar 30, 2006
    Messages:
    106
    Likes Received:
    0
    这个问题经常遇到。
     
  14. kuangri

    kuangri New Member

    Joined:
    Mar 8, 2006
    Messages:
    62
    Likes Received:
    0