Jump to content

Multiple images on one line


Recommended Posts

Alright so I have an array that holds the code to display certain images and I want to display them four or five across.I have tried all of the following ways and they all display both pictures, but on new linesdocument.write(images[0], images[1]);------------------------------------------document.write(images[0] + images[1]);-----------------------------------------display = new String(images[0], images[1]);document.write(display);--------------------------------------------display = new String(images[0] + images[1]);document.write(display);

Link to post
Share on other sites

Set each image to display inline first, like so:

images[0].style.display = 'inline';images[1].style.display = 'inline';

The default display value for images is 'block' which automatically breaks the line.

Link to post
Share on other sites

Block? You sure? I just tested a little script like above and my images came out inline, as they do when I'm not document.writing. I used strict and transitional, just to be sure.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>	 <head>		 <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">		 <title></title>	 </head>	 <body>	 <script type="text/javascript">		 s1 = '<img src="kiss.gif" alt="">';		 s2 = '<img src="kiss.gif" alt="">';		 document.write(s1 + s2);	 </script>	 </body> </html>

Carlos, could you maybe be storing something in images[0] etc. that's causing this? What IS in images[0]? Does your style sheet have any declarations that could be interfering?

Link to post
Share on other sites

Right Right i didnt see them sorry. I didnt really use much css, just to set the background and link colors. all the images values are just files paths that i dont really want to post to be honest but i dont see why they would change anything. I am using though Dreamweaver which might automatically change things to different defualts.I tried setting them to inline but they stopped showing up all together. is there something else I need to add for this to work?

Link to post
Share on other sites

I just tried putting 2 IMG elements side-by-side directly into the HTML (definitely quirks mode - no DOCTYPE) and they worked fine. You can try restricting the width of the images and maybe that will fix it; otherwise, we need some demonstration code.

Link to post
Share on other sites
Block? You sure? I just tested a little script like above and my images came out inline, as they do when I'm not document.writing. I used strict and transitional, just to be sure.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>	 <head>		 <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">		 <title></title>	 </head>	 <body>	 <script type="text/javascript">		 s1 = '<img src="kiss.gif" alt="">';		 s2 = '<img src="kiss.gif" alt="">';		 document.write(s1 + s2);	 </script>	 </body> </html>

Carlos, could you maybe be storing something in images[0] etc. that's causing this? What IS in images[0]? Does your style sheet have any declarations that could be interfering?

wow i totally missed it when you suggested it but im pretty sure you were right. i think i had a line break in the array values because i just started from scratch and redid the whole thing and it is working right now. and now that i think back im pretty sure i recall one in there. Good Call. Thanks
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...