Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

need help aligning some text in an UL list

Posted on 2014-01-16
4
Medium Priority
?
243 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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 1000 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 1000 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 34

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

772 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