V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
013231
V2EX  ›  CSS

這個例子中, outer 比 container 高出幾個像素, 這個高度差是如何產生的? 如何消除?

  •  
  •   013231 · May 13, 2014 · 4625 views
    This topic created in 4366 days ago, the information mentioned may be changed or developed.
    http://jsfiddle.net/6tE9z/

    <div id="outer">
    <div id="container">
    <div id="element">
    some text
    </div>
    </div>
    </div>

    #container {
    display: inline-block;
    position: relative;
    width: 50%;
    }
    #container:after {
    content: '';
    display: block;
    margin-top: 100%;
    }
    #element {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: silver;
    }

    div {
    margin: 0;
    padding: 0;
    }

    #outer {
    background-color: blue;
    }
    3 replies    2014-12-05 12:28:44 +08:00
    nijux
        1
    nijux  
       May 13, 2014   ❤️ 2
    http://css-tricks.com/fighting-the-space-between-inline-block-elements/

    #container {
    display: inline-block;
    position: relative;
    width: 50%;
    font-size:14px;
    }
    #container:after {
    content: '';
    display: block;
    margin-top: 100%;
    }
    #element {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: silver;
    }

    div {
    margin: 0;
    padding: 0;
    }

    #outer {
    background-color: blue;
    font-size:0;
    }
    icanfork
        2
    icanfork  
       May 13, 2014 via Android
    inline-block产生的
    10yearsme
        3
    10yearsme  
       Dec 5, 2014
    @belin520 Hi~我是广志,十年后(10years.me)的运营经理。我刚刚看到你的回答和v2ex上的其他交流,感觉和我们的技术和团队风格都挺合拍 ,希望可以聊聊。十年后是一个基于梦想的社交网络,我们想用它让年轻人的生活更有未来性,网站是去年年末上线的。我们上个月刚拿到创新谷VC百万元天使轮融资,现在在招募Web前端开发的人才。可以加我的微信lgz715314聊聊,交个朋友也不错:)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   843 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 21:24 · PVG 05:24 · LAX 14:24 · JFK 17:24
    ♥ Do have faith in what you're doing.