Solved

need help aligning some text in an UL list

Posted on 2014-01-16
4
236 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

930 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

10 Experts available now in Live!

Get 1:1 Help Now