3

At this site, when you hover over a menu item in the large footer menu, there is a gap to the left of the blue li:hover and to the right of the border of the previous li (indicated by the red section below):

enter image description here

I have zoomed into 200% and inspected this region, but cannot see what is causing this gap.

Can you?

Steve
  • 2,066
  • 13
  • 60
  • 115

6 Answers6

5

The spaces that appear are the actual spaces between the inline block tags. If you have

<ul>
    <li>a</li>
    <li>b</li>
    <li>c</li>
</ul>

then the spaces will appear between the inline blocks, just as spaces appear between the words you type.

If you change it to

<ul>
    <li>a</li><li>b</li><li>c</li>
</ul>

Then you no longer see the spaces between the items.

One way to easily demonstrate that this is happening is that you can actually highlight the spaces, cut and paste them.

In order to prevent this from happening, you can set

.footer-menu ul, .footer-menu-links ul {
    font-size:0px;
}

but this may affect child elements without an easy way to rectify it, so you may also be able to use

.footer-menu ul, .footer-menu-links ul {
    word-spacing:-.25em;
}

.footer-menu ul *, .footer-menu-links ul * {
    word-spacing:normal;
}

Or in an HTML5 document, you can simply skip the closing tags to avoid the issue entirely, since it just plain doesn't care.

If that's not possible, you can also use comments to 'block off' the white space like this:

<ul><!-- Comment tags can also be used to block off the whitespace
    --><li>a</li><!--
    --><li>b</li><!--
    --><li>c</li><!--
--></ul>

That allows you to keep the elements separated for the improved legibility of having one item per line, but it is a little more cluttered to read.

Steve K
  • 4,863
  • 2
  • 32
  • 41
  • Is that normal browser behaviour? I thought browsers ignored such spaces. – Steve Jun 01 '16 at 05:06
  • 2
    Browsers ignore whitespace in HTML code, but a
      set to display:block is just like any other block element. If you type a space in it that is not inside any other tags, it will render the space.
    – Steve K Jun 01 '16 at 05:09
  • For instance, to understand the behavior, think of a `block` element as being replaced with a `
    ` and an `inline-block` as being replaced with a ``.
    – Steve K Jun 01 '16 at 05:45
  • I've used `.footer-menu ul, .footer-menu-links ul { font-size:0px; }` but there is now [a gap at the top of each `li`](http://staging.venusanddiamonds.com/). – Steve Jun 01 '16 at 05:54
  • Try the last way I presented, using the word-spacing property, or set the font-size back to what it was before for all children of your `
      ` tags, or as I suggested just remove the end-tags from the `
    • ` elements.
    – Steve K Jun 01 '16 at 06:22
  • I am using Wordpress, so I cannot remove the `` tags. I've used the last way you wrote, but the issue remains. – Steve Jun 01 '16 at 06:56
  • I added the word-spacing property and it seems to fix it just fine in Chrome (51.0.2704.63). The only layout change I see is the horizontal spaces are gone when the property is added. The space doesn't seem to appear even without the extra property in Firefox 31 or IE 11 either. What browser are you seeing the issues in? – Steve K Jun 01 '16 at 23:17
1

It's pretty simple using flexbox

.home .footer-menu {
    display: flex;
    align-items: stretch;
    justify-content: center;
}

now, just play around with the text alignment of the buttons vertically

Louie Almeda
  • 5,366
  • 30
  • 38
0

You can change the css

.home .footer-menu {
    border-bottom: 1px solid #EEE;
    border-top: none;
    margin-bottom: 0;
}

To this will fix the issue

  .home .footer-menu {
    border-bottom: 1px solid #EEE;
    border-top: none;
    margin-bottom: 0;
    font-size: 0; // Added this line
}
Shijin TR
  • 7,516
  • 10
  • 55
  • 122
0

You have to add <!-- --> this with in your li see the below code.

<ul class="footer-menu" id="menu-primary-menu"><li class="first-menu-item menu-item-type-post_type menu-item-object-page menu-item-38" id="menu-item-38"><a href="http://staging.venusanddiamonds.com/about-us">About Us</a></li><!--
--><li class="last-menu-item menu-item-type-post_type menu-item-object-page menu-item-39" id="menu-item-39"><a href="http://staging.venusanddiamonds.com/shopping">Shopping</a></li><!--
--><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-40" id="menu-item-40"><a href="http://staging.venusanddiamonds.com/shipping">Shipping</a></li><!--
 --><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-41" id="menu-item-41"><a href="http://staging.venusanddiamonds.com/jewellery">Jewellery</a></li><!--
--><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-42" id="menu-item-42"><a href="http://staging.venusanddiamonds.com/black-diamonds">Black Diamonds</a></li><!--
--><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-43" id="menu-item-43"><a href="http://staging.venusanddiamonds.com/bespoke">Bespoke</a></li><!-- 
--><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-44" id="menu-item-44"><a href="http://staging.venusanddiamonds.com/coming-soon">Coming Soon</a></li>
</ul>
Mukul Kant
  • 7,074
  • 5
  • 38
  • 53
0

It's white-space. If you write your list like this:

<li id="menu-item1">
    <a>Link</a>
</li><li id="menu-item2">
    <a>Link</a>
</li>

or

<li id="menu-item1">
    <a>Link</a>
</li><!--
--><li id="menu-item2">
    <a>Link</a>
</li>

instead of

<li id="menu-item1">
    <a>Link</a>
</li>
<li id="menu-item2">
    <a>Link</a>
</li>

it will remove the gaps.

Wim Mertens
  • 1,780
  • 3
  • 20
  • 31
0

May b it will be helpful for you.

{ display: inline-block ; } take default margin from left side so you can scoot the elements back into place with negative 4px o margin (may need to be adjusted based on font size of parent). Apparently this is problematic in older IE (6 & 7), but if you don't care about those browsers at least you can keep the code formatting clean.

For your clarification i attached the Fiddle also:

https://jsfiddle.net/hehrvjhx/1/
Asim Iqbal
  • 148
  • 1
  • 7