Results 1 to 4 of 4

Thread: Line Height Issue

  1. #1
    Join Date
    Jul 2008
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Line Height Issue

    I am having trouble with line height in Products navigation list where you click Products button on the left column (see the screenshot below). The problem occurs when a text link, Accessories & Networking/Cables/Routers is long it automatically wraps into 2 lines causing 2nd line to overlap with other link, Computers. Could anyone please help by identifying what is causing the problem in CSS and how to fix it? I use Animated Collapsible DIV v2.01 with my own CSS framework.



    Website: www.dischmedia.com/site
    CSS: www.dischmedia.com/site/css/style.css

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,027
    Thanks
    44
    Thanked 3,210 Times in 3,172 Posts
    Blog Entries
    12

    Default

    Change:

    Code:
    #subnav li a, a:link, a:visited {
    	font-size: 11px;
    	font-weight: normal;
    	height: 16px;
    	background: transparent;
    }
    to:

    Code:
    #subnav li a, a:link, a:visited {
    	font-size: 11px;
    	font-weight: normal;
    	height: auto;
    	line-height:155%;
    	background: transparent;
    }
    You may want to add a line break tag here as well:

    Code:
    			<div id="products" style="display: none">
    				<ul id="subnav" style="font-size:10px; line-height: normal">
    					<li><br><a href="products/keyboard.php">Keyboard</a></li>
    					<li><a href="products/devices.php">Devices</a></li>
    					<li><a href="products/accessories.php">Accessories &amp; Networking/Cables/Routers</a></li>
    					<li><a href="products/monitors.php">Monitors</a></li>
    					<li><a href="products/computers.php">Computers</a></li>
    					<li><a href="products/memory.php">Memory</a></li>
    					<li><a href="products/storage.php">Hard Drives</a></li>
    				</ul>
    			</div>
    By the way, this selector:

    Code:
    #subnav li a, a:link, a:visited {
    takes in all links and all visited links on the page. I think you mean for it to be:

    Code:
    #subnav li a, #subnav li a:link, #subnav li a:visited {
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    mdisch (07-16-2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Many thanks! Now that raises me another question how do I make Accessories & Networking/Cables/Routers' line height shorter with wrapped 2nd line for each links without applying line height for between each of the separated links?

    I often get myself confused with difference between id and class for CSS rule. And when I should use specific tag that only applies with id or class (i.e. div.rule or div#rule) and when I should use id or class name with tag after the name (i.e. .rule div or #rule div). Any tips or tutorials that you can find for me to learn and understand about these CSS Advanced stuff? I usually just fool around until I get all looks right and the way I wanted them to be some of the time.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,027
    Thanks
    44
    Thanked 3,210 Times in 3,172 Posts
    Blog Entries
    12

    Default

    First of all, after looking at this a little more, I decided that this part:

    Code:
    			<div id="products" style="display: none">
    				<ul id="subnav" style="font-size:10px; line-height: normal">
    					<li><br><a href="products/keyboard.php">Keyboard</a></li>
    					<li><a href="products/devices.php">Devices</a></li>
    					<li><a href="products/accessories.php">Accessories &amp; Networking/Cables/Routers</a></li>
    					<li><a href="products/monitors.php">Monitors</a></li>
    					<li><a href="products/computers.php">Computers</a></li>
    					<li><a href="products/memory.php">Memory</a></li>
    					<li><a href="products/storage.php">Hard Drives</a></li>
    				</ul>
    			</div>
    would be simpler, more straightforward, but would still produce the same result if it were like so:

    Code:
    			<div id="products" style="display: none"><br>
    				<ul id="subnav">
    					<li><a href="products/keyboard.php">Keyboard</a></li>
    					<li><a href="products/devices.php">Devices</a></li>
    					<li><a href="products/accessories.php">Accessories &amp; Networking/Cables/Routers</a></li>
    					<li><a href="products/monitors.php">Monitors</a></li>
    					<li><a href="products/computers.php">Computers</a></li>
    					<li><a href="products/memory.php">Memory</a></li>
    					<li><a href="products/storage.php">Hard Drives</a></li>
    				</ul>
    			</div>
    Now, basically what you want is for this part to appear closer together vertically, as though it is one choice or option (which it is):

    Code:
    <li><a href="products/accessories.php">Accessories &amp; Networking/Cables/Routers</a></li>
    For that, you could do:

    Code:
    <li><a href="products/accessories.php" style="line-height:100%;">Accessories &amp; Networking/Cables/Routers</a></li>
    Or you could give it a class or id and style it with that selector in your stylesheet.

    Generally speaking, it is best to keep all styles in the stylesheet(s). A class may be given to one or more elements, and one or more classes may be given to an element. An id should be unique to only one element and only one id per element is allowed. You can also use other selectors, like the tag names, and/or an element's descendants.

    For a full run down on available selectors, see:

    http://www.eskimo.com/~bloo/indexdot.../selectors.htm

    or your favorite css reference. But be aware of the limitations. Not all selectors work in all browsers, the differences are noted in the above linked reference.

    Some confusion can happen because just about all browsers will let you break certain style rules, others will allow certain rules to be broken that not all browsers allow to be broken, no browser will allow you to break all the rules. Any violations allowed by current browsers will likely not be allowed in the future. So for good cross browser support, it is best to just learn the rules and follow them.

    Even that's not enough though, because some browsers need workarounds because they are not up to standards. However, once you have the basics down, these exceptions will be relatively few, and can usually be fairly easily dealt with. Often they will not come up at all.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •