Solved

need help aligning some text in an UL list

Posted on 2014-01-16
4
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 53

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

752 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