Solved

need help aligning some text in an UL list

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

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

831 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