Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align a list and push text to the bottom

Tags:

html

css

I've a 3 boxes list with title, border and brief description.

At the moment it looks like this:

enter image description here

I would like using only CSS to align the green borders and push all the one row titles to the bottom.

The contents and titles are dynamic so, can happen that there will be 1, 2, 3 rows for the title but I always want that titles with less rows starts from the bottom like in the example below.

enter image description here

I can not use Javascript!

Any suggestion will be appreciated.


At the moment the code structure is this:

HTML:

<section id="" class="boxes">
                <ul class="inline">
                    <li>
                        <article>
                            <h2>Mae hyn yn enghraifft prif llawer hwy</h2>
                            <p>
                                Mae llawer o bethau gwych cymaint yn mynd ymlaen yr haf hwn a, beth bynnag yw eich cynlluniau, nawr yw'r amser i fynd i'r afael a eich gwariant.
                            </p>
                            <a class="read-more" href="">Read more &gt;</a>
                        </article>
                    </li>

CSS:

ul.inline {
    display: inline-block;
    list-style-type: none;
    margin: 0 0 20px;
    padding: 0;
    width: 978px;
}

    ul.inline li {
        float: left;
        margin: 0 18px 0 0;
        padding: 0;
        width: 308px;
    }

        ul.inline li h2 {
            border-bottom: 5px solid #34750E;
            color: #34750E;
            font-size: 21px;
            margin: 0 0 10px;
            padding: 0 0 10px;
            position: relative;
        }

        ul.inline li a.read-more {
                color: #34750E !important;
        }

EDIT:

FIDDLE UP HERE

like image 441
Andrea Turri Avatar asked Aug 03 '12 10:08

Andrea Turri


People also ask

How do you move a list to the bottom in HTML?

Add position:relative to your parent tag and position:absolute; bottom:0px to your list, so it sticks to the bottom of the div.

How do I align text to the bottom in HTML?

Use the text-align property to align the inner content of the block element. Use the bottom and left properties. The bottom property specifies the bottom position of an element along with the position property. The left property specifies the left position of an element along with the position property.

How do I move text from top to bottom in HTML?

The <marquee> tag in HTML is used to create scrolling text or image in a webpages. It scrolls either from horizontally left to right or right to left, or vertically top to bottom or bottom to top.


2 Answers

UPDATE

Check this updated fiddle that uses the markup as in your question: http://jsfiddle.net/techfoobar/hmCuj/

Solution logic is basically remains the same.


Check this fiddle: http://jsfiddle.net/techfoobar/5hhdE/1/

HTML

<ul class="headings">
    <li>Heading #1. Heading #1. Heading #1. Heading #1. Heading #1. </li>
    <li>Heading #2</li>
    <li>Heading #3. Heading #3. Heading #3. Heading #3. Heading #3. Heading #3. Heading #3.</li>
</ul>
<ul class="matter">
    <li>Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. </li>
    <li>Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. </li>
    <li>Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. Matter. </li>
</ul>

CSS

ul.headings, ul.matter {
    list-style-type: none;
    vertical-align: bottom;
    white-space: nowrap;
}
ul.headings li {
    font-size:15px;
    font-weight: bold;
    border-bottom: 2px solid #888888;
    display: inline-block;
    padding: 5px 0;
    white-space: normal;
    width: 33.3%;
}
ul.matter li {
    width: 33.3%;
    display: inline-block;
    white-space: normal;
}

Got the idea from this post: How can I positioning LI elements to the bottom of UL list

like image 89
techfoobar Avatar answered Sep 24 '22 03:09

techfoobar


I've set up an example using tables. This is tabular data, it has a header line, and a description line, and multiple columns.

Live Example

<table>
  <thead>
    <tr>
      <th>Event Title 1</th>
      <th>Event Title 2<br>Mutliline</th>
      <th>Event Title 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Event 1 description<br>Multiline!</td>
      <td>Event 2 description</td>
      <td>Event 3 description</td>
    </tr>
  </tbody>
</table>

CSS

th td {
  margin: 5px;
}
th {
  border-bottom: green 2px solid;
  vertical-align: bottom;
}
td {
  vertical-align: top;
}
like image 39
Madara's Ghost Avatar answered Sep 25 '22 03:09

Madara's Ghost