Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS li adding unecessary space

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #42331
    Gingerbread
    Member

    Hello, just recently found this site. It’s neat!

    So, I have an annoying problem:

    My lists add unwanted spacing in between the lines. I think it wants to ‘equal it out’ – Whatever it is, I want to get rid of it.

    Orange is the background color for the

      list, on a yellow div background, so you can see better.

      The HTML (look at source, I don’t know how to make it appear as code, it automatically formats):

      • (1) 5800PIR-RES Wireless Motion Detector
      • (3) 5816 Standard Wireless Door/Window Transmitters with Magnet and Spacer
      • (1) GSM Module
      • (1) 5834-4 Wireless Keychain Remote
      • (1) RJ31 jack and cord set
      • (1) Rechargeable Back-up Battery Pack
      • (1) 9VAC Transformer
      • (1) LYNX Touch Programming Guide
      • (4) Alarm Warning Decals
      • LYNX Touch User Guide

      The CSS:

      .productwrapper li
      {

      width: 48%;
      height:100%;
      float: left;
      margin-right: 4px;
      font-size:11px;
      line-height:110%;
      background-color:orange;

      }

      The Problem ( picture):
      http://imageshack.us/photo/my-images/9/67490038.png/

      See the annoying space? Tried some things such as making the

      • tags on the same line,
        didn’t work.

        It’s on wordpress in the text edit tab for the page, in case that makes a difference.

    #122677
    Gingerbread
    Member

    @srig99, how do you do that? I clicked the ‘code’ button when I highlighted the html, but it formatted anyways.

    #122680
    Gingerbread
    Member

    OK, thank you. The code tag seems to only work on the CSS for some reason, not the HTML. But that doesn’t matter.

    I made a codepen: http://cdpn.io/khsgF

    Cool thing! Can you help?

    #122681
    Gingerbread
    Member

    @srig99

    Hello, thanks for the help!
    It actually works if I restrict the size to the original box I had, too, but once I replace it with my li list it does the same thing!

    #122683
    Gingerbread
    Member

    Not quite, it doesn’t work with my line items and still divides it in a strange way. I actually figured out now how to link to the original code I had, it’s here:

    http://codepen.io/anon/pen/khsgF

    I think it might have something to do with the ‘strong’ tags?

    #122685
    Gingerbread
    Member

    @srig99
    First of all, thank you for your patience.
    Second of all, the pages you linked claim there’s nothing there. :(

    #122687
    Gingerbread
    Member

    Hello,

    @srig99

    Can you put it in a box with this size:
    width:395px;
    height: 140px;

    It seems to be messing up with that size.

    #122689
    Gingerbread
    Member

    Is there a workaround? Should I perhaps make two separate Divs and have a separate list for each? Those dimensions are important :(

    Edit: unfortunately, it seems to not work.

    #122650
    Paulie_D
    Member

    The fact is that you have a couple of extraordinarily long list items there that just aren’t going to fit inside the div you want unless a very small font-size is used.

    #122713
    jurotek
    Participant

    @Gingerbread, would [This…](http://cdpn.io/GEmIt “”) work for you?

    #122717
    wolfcry911
    Participant

    @Gingerbread, [Here’s a pen](http://codepen.io/wolfcry911/full/mqtiL “”) showing different techniques. In each case I used the dimensions you gave above. The font-size used is going to vary depending on the font you specify (I left default san-serif).

    The first is just a replica of your image. The reason for the spaces is that a float will not render higher than a previous float – so the long list items are creating the spaces.

    The second shows two lists with an equal number of list items. But because the li are of different length, you’ll wind up with different length lists. This assumes that the lists are dynamic – if you’re hard coding them, you could alter the number of items each list has.

    The third is a simple single full width list – might be the best option. It would need a slightly smaller font-size to fit everything however.

    Note that in the future, or now if you want to use browser prefixes, you could use css columns to achieve your orginal desired look. The fourth example shows this (with prefixes)

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘CSS’ is closed to new topics and replies.