0

I have some extra space for my responsive nav links that is not being defined anywhere in the CSS. This space is removed after I reduce the page width. Can anyone identify the cause of the extra space, it is baffling me. Here is a fiddle: http://jsfiddle.net/DjftP/

The nav is coded as follows:

<div id="navigation">
    <div class="chunk-nav-hrz-fxd" data-nav-fxd="200">
        <nav>
            <a>Link1</a>
            <a>Link2</a>
            <a>Link3</a>
            <a>Link4</a>
        </nav>
        <nav class="nav-right">
            <a>Link5</a>
            <a>Link6</a>
        </nav>
    </div>
</div>

LESS:

.chunk-nav-hrz-fxd                    {.chunk; padding: 0; .clearfix}
.chunk-nav-hrz-fxd nav                {line-height: 40px; .clearfix; margin-bottom: 0; padding-left: 0; display: inline-block; float: left}
.chunk-nav-hrz-fxd .nav-right         {float: right}
.chunk-nav-hrz-fxd a                  { margin-bottom: 0; padding: @baseline/2 @baseline}
.chunk-nav-hrz-fxd a:hover            {text-decoration: none}
.chunk-nav-hrz-fxd a:last-child       {border-right: 0}

Before window resize with extra space:

enter image description here

After window resize with space somehow being removed:

enter image description here

Alex
  • 2,651
  • 2
  • 25
  • 45

2 Answers2

3

Your nav elements use <a> tags which have a default display of inline, so your whitespace is being counted.

See this fiddle. Where I removed all the whitespace between your HTML tags.

Bradley Trager
  • 3,570
  • 3
  • 26
  • 33
1

Your element are inline block, which give the roperties of block element and inline aswell.

One of the inline property is the white space character. When the HTML is compiling. it compile every whitespace character into a single whitespace (with the exception of pre elements). Return character, tabulation and space are all compiled as whitespace and create the visible space. See this fiddle to see the said behavior.

But you resize function is using DOM manipulation method. When using those methods, it does not create the new line character or the tabulation like your source code. And this is why the whitespace aren't shown after resize.

Solution : trigger the resize

$(window).smartresize(function () {
    checkSize()
}).trigger('resize');

http://jsfiddle.net/DjftP/1/

Community
  • 1
  • 1
Karl-André Gagnon
  • 33,662
  • 5
  • 50
  • 75