1

我在元素#inner 上设置了 .outerHeight(true) 但目前它返回高度值

即:304 ff:317 铬:289

谁能解释我可能在哪里出错?

JS

var wH = $(window).height(),
    wrapper = $('#wrapper'),
    inner = $('#inner'),
    innerH = inner.outerHeight(true),
    more = inner.find('.more'),
    close = inner.find('.close'),
    titleH = $('#title').outerHeight(true),
    excerpt = $('.excerpt'),
    excerptH = excerpt.outerHeight(true),
    lowerH = $('.lower').outerHeight(true),
    upper = inner.find('.upper'),
    footerH = $('#footer').height()
    body = $('body');

// Set #wrapper off page
wrapper.css('bottom', -innerH);

// Store tier1 calculation as data attribute
wrapper.data('tier1', -innerH+titleH+footerH);
console.log(innerH);
//console.log(-innerH+titleH+footerH);
// Animate #wrapper above #footer
wrapper.delay(500).animate({ bottom: wrapper.data('tier1') }, 400);

CSS

body{font-family:Arial,Helvetica,sans-serif;overflow: hidden;}
h1{text-align:center;width:600px;margin:0 auto;padding:20px 0 45px;font-size:28px;font-weight:bold;line-height:26px;}
p{margin-bottom:20px;}


#tiers{background:#f2f2f2;height:100%;}
#wrapper{width:100%;position:absolute;bottom:0;left:0;background:#dedede;}
#inner{width:840px;margin:0 auto;}
.upper{display:none;}
.upper p{margin-bottom:0;}
.col{width:410px;}
.btn{background: #000000;color: #FFFFFF;display: block;font-size: 20px;font-weight: bold;width:30px;height:30px;text-align:center;line-height:30px;position: absolute;text-decoration: none;}
.more{top:20px;right:20px;}
.close{display:none;top:60px;right:20px;}
.excerpt{display: block;}

HTML

<body class="tier1">

  <div id="tiers">
      <div id="wrapper">
      <div id="inner" class="clearfix">
          <a href="#" class="close btn">-</a>
          <a href="#" class="more btn">+</a>
          <div class="lower">
            <h1 id="title">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</h1>
            <p class="excerpt">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
              tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
              quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
              consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
              cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
              proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
              tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
              quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
              consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
              cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
              proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          </div>
          <div class="upper">
            <div class="col left"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
            proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div>
            <div class="col right"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
            proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div>
          </div>
      </div>
    </div>
  </div>
  <div id="footer"></div>




</body>

页面链接:http: //bit.ly/IA65Mb

凯尔

4

1 回答 1

0

我能够发现一些差异:

  • p有一个 20pxmargin-bottom传播到#innerchrome 中。我不记得这个功能的细节,但我想我曾经听说过它实际上是正确的行为。我认为只有铬有它。查看示例
  • 由于某种原因#excerpt,ff 和 chrome 的高度不同 - 文本渲染可能略有不同?

我认为解决第一个问题可以解决您遇到的问题。跨浏览器获得完全相同的结果是一种矫枉过正。

于 2012-05-04T12:50:37.930 回答