Connecting Tech Pros Worldwide Forums | Help | Site Map

Horizontal scroll - img & p

Newbie
 
Join Date: May 2008
Posts: 19
#1: Jul 16 '08
Hello everyone!

Im having a little trouble with my horizontal scrolling set of video thumbnails.

I've got 6 video thumbnails that the user scrolls through horizontally, I've got this working fine with the images. However, I want a small peice of text underneath each image - the title of the video.

But i can't get the text to display below the image without messing up the horizontal scrolling!

Here's an online example:
http://10.132.0.167/medialab/horizon...l_example.html

Here's the code:

Expand|Select|Wrap|Line Numbers
  1. <style>
  2. .photo-list {
  3.  margin: 0;
  4.  padding: 0;
  5.  height: 130px;
  6.  width: 558px;
  7.  list-style: none;
  8.  overflow: auto;
  9.  white-space:nowrap;
  10. }
  11. .photo-list li {
  12.  display: inline;
  13. }
  14. .photo-list p {
  15.  display: inline;
  16. }
  17. .photo-list img {
  18.  height: 82px;
  19.  width: 108px;
  20.  border: 0;
  21. }
  22.  
  23. </style>
  24.  
  25. </head>
  26.  
  27. <body>
  28.  
  29. <ul class="photo-list">
  30.      <li><img src="images/vid_thumb.jpg" alt=""><p>video 1</p></li>
  31.      <li><img src="images/vid_thumb.jpg" alt=""><p>video 2</p></li>
  32.      <li><img src="images/vid_thumb.jpg" alt=""><p>video 3</p></li>
  33.      <li><img src="images/vid_thumb.jpg" alt=""><p>video 4</p></li>
  34.      <li><img src="images/vid_thumb.jpg" alt=""><p>video 5</p></li>
  35.      <li><img src="images/vid_thumb.jpg" alt=""><p>video 6</p></li>
  36. </ul>
  37.  
Your help would be much appreaciated!

Thanks in advance

-Ryan

Newbie
 
Join Date: May 2008
Posts: 19
#2: Jul 18 '08

re: Horizontal scroll - img & p


Maybe i should try putting the img and p into separate rows of a table? What do you reckon guys?
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,171
#3: Jul 18 '08

re: Horizontal scroll - img & p


Try removing

.photo-list p {
display: inline;
}

from the CSS you don't want the paragraph inline, you want it below the image, you may want to centre the text in the paragraph though.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,571
#4: Jul 18 '08

re: Horizontal scroll - img & p


A <p> is a block level element and cannot be made 'inline'.

What you can do is make the image 'display:block' and then, if necessary, adjust height/width and float them left to actually keep them inline.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,171
#5: Jul 18 '08

re: Horizontal scroll - img & p


Quote:

Originally Posted by drhowarddrfine

A <p> is a block level element and cannot be made 'inline'.

Yes you can in the same way you can make span (and other inline elements) block using display: block. In fact that is what these styles are for surely.

Anyway try this completely conforming code (at least it validates in the W3C HTML and CSS validators)

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Div inline test</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  8. <style type="text/css">
  9. p {
  10.     display: inline;
  11. }
  12. span {
  13.     display: block;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <p>Division 1</p>
  19. <p>Division 2</p>
  20. <div>
  21.   <span>Span 1</span><span>Span 2</span>
  22. </div>
  23. </body>
  24. </html>
  25.  
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,171
#6: Jul 18 '08

re: Horizontal scroll - img & p


As an after thought do you mean "should not" rather than "cannot"? If so why?
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,571
#7: Jul 18 '08

re: Horizontal scroll - img & p


I haven't a clue why I said that.
Newbie
 
Join Date: May 2008
Posts: 19
#8: Jul 21 '08

re: Horizontal scroll - img & p


Quote:

Originally Posted by Banfa

Try removing

.photo-list p {
display: inline;
}

from the CSS you don't want the paragraph inline, you want it below the image, you may want to centre the text in the paragraph though.

This results in the same problem. Removing ' display: inline;' and taking the text out of the <p> tags does nothing, the text is still displayed next to the images, not underneath
Newbie
 
Join Date: May 2008
Posts: 19
#9: Jul 21 '08

re: Horizontal scroll - img & p


Quote:

Originally Posted by drhowarddrfine

A <p> is a block level element and cannot be made 'inline'.

What you can do is make the image 'display:block' and then, if necessary, adjust height/width and float them left to actually keep them inline.

displaying the image as 'block' does make the text go under the image but it also makes the overflow display vertically, not horizontally.
Floating the images 'left' makes the images bunch together in an untidy fashion.
Newbie
 
Join Date: May 2008
Posts: 19
#10: Jul 21 '08

re: Horizontal scroll - img & p


Quote:

Originally Posted by Banfa

Yes you can in the same way you can make span (and other inline elements) block using display: block. In fact that is what these styles are for surely.

Anyway try this completely conforming code (at least it validates in the W3C HTML and CSS validators)

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Div inline test</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  8. <style type="text/css">
  9. p {
  10.     display: inline;
  11. }
  12. span {
  13.     display: block;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <p>Division 1</p>
  19. <p>Division 2</p>
  20. <div>
  21.   <span>Span 1</span><span>Span 2</span>
  22. </div>
  23. </body>
  24. </html>
  25.  

I understand how this code shows the values of 'inline' and 'block, how can this effectively be applied to my problem?
Thanks for your help :-)
Newbie
 
Join Date: May 2008
Posts: 19
#11: Jul 21 '08

re: Horizontal scroll - img & p


Well, I've stuck the content into a table. Image in the top row, text in the bottom. There is a div holding the table with overflow: auto and white-space: nowrap... works a treat :-) I didn't really wanna use table, but se lave!

Here's the working code:

Expand|Select|Wrap|Line Numbers
  1. <style>
  2. #holder {
  3.  margin: 0;
  4.  padding: 0;
  5.  height: 230px;
  6.  width: 358px;
  7.  list-style: none;
  8.  overflow: auto;
  9.  white-space:nowrap;
  10. }
  11.  
  12. </style>
  13.  
  14.  
  15. </head>
  16.  
  17. <body>
  18.  
  19. <div id="holder">
  20. <table width="700" height="151" border="0">
  21.   <tr>
  22.     <td width="158"><img src="images/vid_thumb_02.jpg" width="130" height="120" /></td>
  23.     <td width="379"><img src="images/vid_thumb_02.jpg" width="130" height="120" /></td>
  24.     <td width="33"><img src="images/vid_thumb_02.jpg" alt="" width="130" height="120" /></td>
  25.     <td width="33"><img src="images/vid_thumb_02.jpg" alt="" width="130" height="120" /></td>
  26.     <td width="33"><img src="images/vid_thumb_02.jpg" alt="" width="130" height="120" /></td>
  27.     <td width="38"><img src="images/vid_thumb_02.jpg" alt="" width="130" height="120" /></td>
  28.   </tr>
  29.   <tr>
  30.     <td><div align="center">mong vid</div></td>
  31.     <td><div align="center">bong vid</div></td>
  32.     <td><div align="center">long vid</div></td>
  33.     <td><div align="center">hong vid</div></td>
  34.     <td><div align="center">song vid</div></td>
  35.     <td><div align="center">trong vid</div></td>
  36.   </tr>
  37. </table>
  38. </div>
  39.  
  40. </body>
  41.  
Thank you to everyone for their help!
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,171
#12: Jul 21 '08

re: Horizontal scroll - img & p


Quote:

Originally Posted by ryrocks

This results in the same problem. Removing ' display: inline;' and taking the text out of the <p> tags does nothing, the text is still displayed next to the images, not underneath

That isn't what I said to do, I said remove the CSS I said nothing about removing the text from the <p> tags.
Newbie
 
Join Date: May 2008
Posts: 19
#13: Jul 23 '08

re: Horizontal scroll - img & p


Quote:

Originally Posted by Banfa

That isn't what I said to do, I said remove the CSS I said nothing about removing the text from the <p> tags.

Well I get the same result whether I keep it in the P tags or not, It's fixed now anyway... so nyah!
Reply