chiiyo
Apr 9 2005, 02:29 AM
Hi all~ Need some help with CSS. I'm trying to get two divs to reside side by side. Each div has a few lines of words and I need the two div blocks to be just next to each other if possible. I went through many methods and this is what I've come up with so far that works pretty well... The trial page is here. CODE <html><head> <style type="text/css"> #commentforma { margin-top: 2em; margin-bottom: 2em; margin-left: 2em; margin-right: 1em; text-align: center; float: left } #commentformb { margin-top: 2em; margin-bottom: 2em; margin-left: 2em; margin-right: 2em; text-align: center; float: left } input { font-size: 11px; line-height: 16px; letter-spacing: 1px; font-family: tahoma, helvetica, arial, sans-serif; color : #000; text-align: center } label { font-size: 11px; line-height: 16px; letter-spacing: 1px; font-family: tahoma, helvetica, arial, sans-serif; color : #CCC; text-align: center } textarea { font-size: 11px; line-height: 16px; letter-spacing: 1px; font-family: tahoma, helvetica, arial, sans-serif; color : #000; text-align: center } </style> </head><body> <form method="post" action="$tmp[php_self]?show_id=$tmp[post_id]#$tmp[post_id]"> <input type=hidden name='fields[post_id]' value='$tmp[post_id]' /> <div id="commentforma"><label for="name">name</label><br /><input type="text" name="fields[name]" tabindex="1" size="20" maxlength="50" class='pc_input' id="name" /><br /><label for="email">email</label><br /><input type="text" name="fields[email]" tabindex="2" size="20" class='pc_input' id="email" /><br /><label for="url">url</label><br /><input type="text" name="fields[homepage]" size="20" tabindex="3" class='pc_input' id="url" /></div> <div id="commentformb"><label for="comments">comments</label><br /><textarea name="fields[comments]" rows="6" cols="25" tabindex="4" class='pc_input' wrap="soft" id="comments"></textarea><br /><input type="submit" name="doit" value="submit" tabindex="5" class='pc_submit'></div> </form> </body></html>
(I'm trying to customise Poster Child by the way...) Problem is, this code doesn't work in IE 5.2 for Mac! It looks like IE:mac doesn't recognise the float command in CSS (which has existed since Netscape 4.0, for goodness sakes, but apparently IE:mac is ridiculously buggy and has been horribly ported to OS X, so it doesn't even recognise something as simple as float) and thus the div blocks end up one after the other, placed vertically. I'm literally pulling my hair out over this, I need the information to be in two div blocks because the elements have to centralised within their own div block but it would be really good if I could get them to be side by side. Does anyone know how to do this with CSS without having to resort to position: relative or absolute? I'm not sure whether position: relative or absolute would work because I'm nesting this bunch of div blocks within another div tag. Using another div to "contain" the two div tags doesn't work in IE:mac too, plus it's really buggy, once the browser window size changes, it will switch back to being one above the other. For now I'm resigned to having it work on Safari and not have it work on IE:mac. Problem is I'm also scared it won't work on Windows browsers (spent too much time on IE:mac haven't tested it with other browsers yet), so if the above code doesn't work in your browser, tell me please...
Reply
miCRoSCoPiC^eaRthLinG
Apr 9 2005, 03:23 AM
Hey, That's how I'd created my NOTE tag, by nesting 5 other divs inside a main container div. The header div has 3 of these divs nested inside it, and placed side-by-side using the float attribute. However, I used float: left, right & center to place them. Take a look at this tutorial: http://www.astahost.com/howto-3-custom-bbc...note-t4009.htmlIt might just help you. However, for some strange reason, I'd to draw the right-most floated div first and then the left & center. Or else these div's would turn up at random places. Even I'm struggling with CSS so I couldn't come up with a valid explanation as to why it was working this way. But hey, IT WORKS !! lol.. See if that NOTE tag dissertation helps you..
Reply
jipman
Apr 9 2005, 09:17 AM
Or you just could use the <SPAN> tag instead of the <DIV> tag the span one doesn't add a linefeed to the output so you can have to <span>'s on one line. If that is what you mean. here for more info : http://www.w3schools.com/tags/tag_span.asp
Reply
chiiyo
Apr 9 2005, 04:08 PM
Thanks jipman and m^e, but unfortunately, still doesn't solve the problem... >_< The Span tag works literally the same as the div, as in it still doesn't work, and the note example isn't so much talking about two div blocks placed next to each other. To put my question baldly: is there some way I can make two div blocks next to each other without 1. Using the float attribute 2. Using position: absolute or position: relative <-- or if these two are needed, would the code still work if it's nested within another div tag.
Reply
jipman
Apr 9 2005, 04:32 PM
THen chiiyo you are doing something wrong here. Here's an example of the difference of DiV and Span that I created just for you  CODE <html> <head> <style type="text/css"> .a {background-color: #ffff00;border:1px solid black;} .b {background-color: #0000ff;border:1px solid black;}
.c {background-color: #ff0000;border:3px solid black;} .d {background-color: #00ff00;border:1px dashed black;} </style> </head> <span class="a">These are two different spans</span> <span class="b">so it's clearly that the two are side by side</span> <p> <p> <div class="c">This is a div example</div> <div class="d">so you see the difference</div> </html>
So I'm sure it should work for you 
Reply
chiiyo
Apr 10 2005, 04:21 AM
Hmm, I understand what you mean, jipman, about how spans are inline and divs are not, but the problem is I have is that I have several LINES of information that I need to be in a block, and the span tag isn't able to "contain" the information in one ordered block. I need two blocks of information, each containing several lines, to be inline. Span can't help me there. To use your example to illustrate what I mean, I added a second line to each of the span and div tags. CODE <html> <head> <style type="text/css"> .a {background-color: #ffff00;border:1px solid black;} .b {background-color: #0000ff;border:1px solid black;}
.c {background-color: #ff0000;border:3px solid black;} .d {background-color: #00ff00;border:1px dashed black;} </style> </head> <span class="a">These are two different spans<br />(A second line for the yellow span)</span> <span class="b">so it's clearly that the two are side by side<br />(A second line for the blue span)</span> <p> <p> <div class="c">This is a div example<br />(A second line for this div, this is what i mean by having several lines of information)</div> <div class="d">so you see the difference<br />(Do you see once I add a second line the effect is changed?)</div> </html>
The only way I can contain the lines of information is by using div tags, so my problem is still unsolved...
Reply
jipman
Apr 10 2005, 10:14 AM
Hmm yes i see, howabout using a table? CODE <html> <head> <style type="text/css"> .a {background-color: #ffff00;border:1px solid black;} .b {background-color: #0000ff;border:1px solid black;}
.c {background-color: #ff0000;border:3px solid black;} .d {background-color: #00ff00;border:1px dashed black;} </style> </head> <table> <tr><td><div class="a">These are two different divs<br>(A second line for the yellow div)</div></td> <td><idv class="b">so it's clearly that the two are side by side<br>(A second line for the blue div)</div></td> </table> </html>
This would be better than using postion stuff...
Reply
chiiyo
Apr 10 2005, 04:25 PM
Yeah, I'm a big table lover, my brain still works the table way, I don't know how many times I've thought, I could just put that in a cell, colspan that, rowspan that, width that.... BUT I'm trying to make my site XHTML 1.0 compliant, and that means trying as hard as possible not to use tables for layout purposes. Which goes back to the question, is there, or isn't there a way to place two div blocks next to each other without using float or position?
Reply
Tobias
Apr 11 2005, 01:43 AM
Maybe instead of using float for both divs, try absolute positioning one. Then instead of floating the second one, use margins to move it side to side. If you're trying to get the divs closer together then just change the margins of the boxes. Hope this is what you wanted. [CODE] <html> <head> <title>CSS</title> <style type="text/css"> #leftbox { position: absolute; margin: 0 0 0 50px; padding: 0; width: 150px; height: 150px; } #centerbox { margin: 0 0 0 225px; padding: 0; width: 150px; height: 150px; } </style> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080"> <div id="leftbox"> <span>This should work the way you want it to.</span> </div> <div id="centerbox"> <span>Then you can put your form in here.</span> </div> </BODY> </HTML>
Reply
chiiyo
Apr 22 2005, 08:21 AM
Thank you very much Tobias, that solved my problem! I used ems instead of px to change the margins, because IE:mac seems to respond better to ems than to pxs, but either than that, the code worked perfectly, even when nested within other divs. Exactly what I was looking for, thank you! Took me a while to actually try it out, what with exams and other stuff, but thanks~ Someone can close this post if you want, problem solved~
Reply
Recent Queries:--
div side by side - 0.73 hr back. (1)
-
css float div side by side - 2.82 hr back. (1)
-
place div side by side - 3.40 hr back. (1)
-
side by div - 3.93 hr back. (1)
-
css side-by-side - 3.99 hr back. (1)
-
css menu side block - 4.26 hr back. (1)
-
css position div side by side - 4.74 hr back. (1)
-
put div side by side - 5.88 hr back. (1)
-
problem putting two divs side by side - 6.20 hr back. (1)
-
two divs side by side - 6.21 hr back. (1)
-
how to place 2 divs side by side - 6.74 hr back. (1)
-
two side by side divs - 7.29 hr back. (1)
-
div side by side html - 9.15 hr back. (1)
-
tables side by side using div - 9.17 hr back. (1)
Similar Topics
Keywords : putting, div, blocks, side, side, css, woes
- Almost 3d Blocks
Using CSS borders (6)
- putting a background color makes a slight problem
(7) take a look at this code Test 1 Test2 Test3
when the tag for the background color of the page is put in, it makes the top cell for the table
appear slightly off. however when it's not in, the cell inside the table appears fine....
Looking for putting, div, blocks, side, side, css, woes
|
*SIMILAR VIDEOS*
Searching Video's for putting, div, blocks, side, side, css, woes
|
advertisement
|
|