Solved

need help aligning some text in an UL list

Posted on 2014-01-16
4
235 Views
Last Modified: 2014-01-17
I'm trying to create the following, using images as the "bullet" in an unordered list:

 ------   1.) title text
|      |       content text, can be
|      |       multiple rows
 ------

 ------   2.) title text
|      |       content text, can be
|      |       multiple rows
 ------

I have everything working pretty well, except the content text aligns under the number. is there a simple way to indent it like above,

Here's my code:

        <ul id="mainList">
            <li id="one"><div>
                <h2>1.) Content Title</h2>
                Content Text
            </li>
            <li id="two">
               <h2>2.) Content Title</h2>
                Content Text
            </li>
         </ul>

Open in new window


and my CSS:

        #mainList { list-style-type: none; padding-left: 10%; padding-right: 10%; }
        #mainList li { padding-bottom: 15px; }
        #one { background: url(/images/person.png) no-repeat center left; padding-left: 77px; min-height: 74px; }
        #two { background: url(/images/paper.png) no-repeat center left; padding-left: 77px; min-height: 77px; }

Open in new window


TIA :)
0
Comment
Question by:Big Monty
4 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 250 total points
ID: 39787615
I think you had it but you have an unclosed div in your first li tag
A little tweaking  http://jsbin.com/utAbavE/1/edit
<!DOCTYPE html>
<html>
<head>
  <style>
            #mainList { list-style-type: none; padding-left: 10%; padding-right: 10%; }
        #mainList li { padding-bottom: 15px; }
        #one { background: url(http://ansnuclearcafe.org/wp-content/uploads/2010/09/person-icon.gif) no-repeat center left; padding-left: 77px; min-height: 74px; }
        #two { background: url(http://ansnuclearcafe.org/wp-content/uploads/2010/09/person-icon.gif) no-repeat center left; padding-left: 77px; min-height: 77px; }
    h2{margin-left:-60px;}
  </style>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
          <ul id="mainList">
            <li id="one">
                <h2>1.) Content Title</h2>
              <p>Content Text</p><p>Content Text</p><p>Content Text</p>
            </li>
            <li id="two">
               <h2>2.) Content Title</h2>
                <p>Content Text</p><p>Content Text</p><p>Content Text</p>
            </li>
         </ul>
</body>
</html>

Open in new window

0
 
LVL 8

Expert Comment

by:Surrano
ID: 39787802
Well this is not "real" numbering as you set list-style-type to none. Try to hack it further by using <p> as proposed by Scott and adding a sufficient left-indent to <p>.
To have the "title" part of the h2 tag, i.e. the one that comes after "1.)" to be aligned to same place, change it to a <li> with a different class that has list-style-type as you need, and embed the <p> *inside* that <li>:

        <ul id="mainList">
            <li id="one"><ul>
                <li class="li-title">Content Title
                  <p>Content Text</p>
                </li></ul>
            </li>
            <li id="two"><ul>
               <li class="li-title">Content Title
                  <p>Content Text</p>
               </li></ul>
            </li>
         </ul>

Open in new window

0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
ID: 39788752
http://jsfiddle.net/GaryC123/LW9JW/1/

No extra markup (bar a bit of css) but it only works up to 9 items then it gets screwed up.
0
 
LVL 32

Author Closing Comment

by:Big Monty
ID: 39790191
the margin-left syntax on the h2 or li:before worked great, just what I needed. I did have a closing DIV, the list I'm working with is actually longer and I just forgot to paste in the closing tag.

thanks for the help :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now