Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6687515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:17:54+00:00 2026-05-26T05:17:54+00:00

Example: jsfiddle.net/h5sE6/ css: ul { float: left; margin-right:20px; } ul li { height: 3em;

  • 0

Example: jsfiddle.net/h5sE6/

css:

ul {
    float: left;
    margin-right:20px;
}
ul li {
    height: 3em;
    border: 1px solid #ff0000;
    width:200px;
}

html:

<ul>
    <li> Some text</li>
    <li>Some text<br />some more text</li>
    <li>some test text3</li>
    <li>even more text<br />and more</li>
</ul>
<ul>
    <li> Some text</li>
    <li>Some text<br />some more text</li>
    <li>some test text</li>
    <li>even more text<br />and more</li>
</ul>

This is trivial with vertically aligning text and making the height equal to the line-height if you have one line only but any more than that, things look really screwy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:17:54+00:00Added an answer on May 26, 2026 at 5:17 am

    You can do it with a helper :before element and by adding a nested <span>:

    ul li span {
        display: inline-block;  
        vertical-align: middle;     
    }
    
    ul li:before{
        content: '';
        display: inline-block;
        vertical-align: middle;
        height: 100%;       
    }
    

    Here’s a demo of it in action.

    This works because two inline-block elements will vertically align with each other. The :before rule creates an inline-block element that is the same height as its parent, which the variable height <span> can vertically align with.

    For a complete explanation of how it works, see this answer about vertically aligning images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For CSS, we know that vertical margin collapses, such as in example: http://jsfiddle.net/rbxL7/5/ (The
Example: http://jsfiddle.net/xUrDc/ I'm trying to surround each li with a border exactly one pixel
Example: http://jsfiddle.net/NBWmU/1/ I'm using the following CSS to make the background of my div
i have a problem with the revert speed. Here is a working example http://www.jsfiddle.net/V9Euk/94/
This is example http://jsfiddle.net/4BjVv/6/ $(function(){ $('ul#crumbs li a').bind('click',crumbClick) }); function crumbClick(){ $('ul#crumbs .selected').removeClass('selected'); $(this).parents('li').addClass('selected');
Consider this example: http://jsfiddle.net/treeface/P8JbW/ HTML : <div id=test> <img src=http://ycombinator.com/images/y18.gif /> </div> CSS :
Please take a look at the following example: http://jsfiddle.net/MVfVD/ I want the overlayedFrameFooter div
Block is blinking on .hover() Here is a full example - http://jsfiddle.net/xBEjQ/ How to
I think it is best described by looking at an example: http://jsfiddle.net/kV9yn/16/ That is
Example: http://jsfiddle.net/wCFBw/25/ input { color: black; } <input type=text value=This is black /> <input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.