Please support our HTML and CSS advertiser: Lunarpages Web Hosting
![]() |
•
•
Join Date: Dec 2005
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 0
I'm trying to line up horizontally four images with a small text link underneath them. I can't get the text to go underneath. How can I do this? My code so far:
.cards { top: 5px; background: #66AAFF; height: 124px; width: 537px; position: absolute;}
.cards ul { margin: 0; padding 0; list-style-type: none; }
.cards ul li { width: 103px; display: inline; }<div class="cards"> <ul id="list"> <li><a href="layout.php"><img src="card.png" border="0" /></a>Cards</li> <li><a href="layout.php"><img src="card.png" border="0" /></a>Cards</li> <li><a href="layout.php"><img src="card.png" border="0" /></a>Cards</li> <li><a href="layout.php"><img src="card.png" border="0" /></a>Cards</li> </ul> </div>
Last edited by riscphree : Nov 10th, 2008 at 5:30 pm.
•
•
Join Date: Jun 2004
Posts: 231
Reputation:
Rep Power: 5
Solved Threads: 0
duno why my response didnt show up wrap cards in <p class="imgtxt">Cards</p>
p.imgtxt {
margin:0;
padding:0;
width:103px;
text-align:center; /* optional */
}•
•
Join Date: Dec 2005
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 0
That makes them go vertical though.
http://www.riscit.info/jquery/lols2.html
Anyway to get them back horizontal?
http://www.riscit.info/jquery/lols2.html
Anyway to get them back horizontal?
•
•
Join Date: Jun 2004
Posts: 231
Reputation:
Rep Power: 5
Solved Threads: 0
.cards ul li { width: 103px; display: inline; }
to
.cards ul li { width: 103px; float:left; }•
•
Join Date: Jun 2004
Posts: 231
Reputation:
Rep Power: 5
Solved Threads: 0
after the </ul> add <div class="clear"></div>
to clear out the float left so you can put stuff below
.clear { clear:both; }to clear out the float left so you can put stuff below
•
•
Join Date: Dec 2005
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 0
I can't quite figure out the clear stuff. Is it ok to use negative numbers for positioning?
I've updated my page: http://www.riscit.info/jquery/lols2.html
I've updated my page: http://www.riscit.info/jquery/lols2.html
Here's what you need. I've added some span elements to control the portion of the text. Hope this will help you up. Enjoy
html Syntax (Toggle Plain Text)
<html> <head> <title></title> <style type="text/css"> .cards { width: 537px; height: 140px; float: left; margin: 0; padding: 0; background: #66AAFF; overflow: hidden; } .cards ul { list-style-type: none; /* line-height uses the total height of "cards" class */ line-height: 140px; float: left; width: 534px; margin: 0; padding: 0; } .cards li { width: auto; line-height: 140px; float: left; margin: 5px 0 5px 0; padding: 0; display: inline; } .cards span { float: left; clear: both; text-align: left; line-height: 36px; margin: 0; /* Base on 100pixel width image, get the half of it to center your text. So it wil take 50px to the padding to center the text! You may adjust the pixel rate to any desired amount base on the width of your image. */ padding: 0 50px; } .cards li img { margin: 0; padding: 0 5px; border: none; width: auto; height: auto; } </style> </head> <body> <div class="cards"> <ul id="list"> <li><a href="layout.php"><img src="images/type_red1.jpg" border="0" /></a><span>Cards</span></li> <li><a href="layout.php"><img src="images/type_red1.jpg" border="0" /></a><span>Cards</span></li> <li><a href="layout.php"><img src="images/type_red1.jpg" border="0" /></a><span>Cards</span></li></ul> </div> </body> </html>
Last edited by essential : Nov 14th, 2008 at 5:46 am.
![]() |
Similar Threads
Other Threads in the HTML and CSS Forum
- login box not working (JavaScript / DHTML / AJAX)
- I need help with my website. Using Dreamweaver. (JavaScript / DHTML / AJAX)
Other Threads in the HTML and CSS Forum
- Previous Thread: please help me in this question plz.its urgent
- Next Thread: Another ie & ff viewing problem
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode