Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
DIVs side by side not underneath?
Old 04-01-2009, 03:40 AM DIVs side by side not underneath? should be in CSS
Ultra Talker

Posts: 316
Trades: 0
I would like to center my DIVs inside a DIV but would also like them to be side by side where there is room.

At the moment they are on top of each other.

http://londonlabs.co.uk/help/squares/

I tried using float to make them go next to each on the horizonal plane but this broke the centering.

Please see attachment for further info:
http://www.webmaster-talk.com/attach...1&d=1238585531

Any ideas?

Thanks

Code:
@charset "utf-8";
#wrapper {
    margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    width: 90%;
    background-color:#99CC00;
    border-style:solid;
    border-width:1;
    border-color:#000000;
}
.box {
    border: 1px solid #CCCCCC;
    margin: 0 auto;
    padding: 5px;
    height: 300px;
    width: 300px;
}
Attached Images
File Type: jpg divs.JPG (23.3 KB, 5 views)

Last edited by Joe3000; 04-01-2009 at 07:32 AM..
Joe3000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-01-2009, 06:26 AM Re: DIVs side by side not underneath?
Extreme Talker

Posts: 189
Trades: 0
for the boxes try width:50%;
simster is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 06:35 AM Re: DIVs side by side not underneath?
Ultra Talker

Posts: 316
Trades: 0
Quote:
Originally Posted by simster View Post
for the boxes try width:50%;
I don't want them 50% but it didnt work anyways.

Thanks for trying.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 10:47 AM Re: DIVs side by side not underneath?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
If you want the divs to adjust when the browser window is reduced, you're going to have to use percentages for all your widths.

The only way you're going to get the boxes side by side is to float them.

Try this method:

HTML:
Quote:
<div id="wrapper">
<div id="boxWrap"
<div class="box">box1</div>

<div class="box">box1</div>

<div class="box">box1</div>
</div>

</div>
CSS:
Quote:
#wrapper {
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
width: 90%;
background-color:#99CC00;
border-style:solid;
border-width:1;
border-color:#000000;
position: relative;
overflow: auto; /*clears the floated divs inside it */
}
#boxWrap{
width: 90%;
margin: 0 auto;
text-align: center;
}

.box {
border: 1px solid #CCCCCC;
margin: 0 auto;
padding: 5px;
height: 300px;
width: 31%;
float: left;
}
I removed the clearing divs, you don't need them if you use overflow:auto as shown above.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 11:51 AM Re: DIVs side by side not underneath?
Ultra Talker

Posts: 316
Trades: 0
Thanks.

I don't want the boxes to change size.

I just want them centered but with more than one on the horizontal plane (however many can fit which depends on the width of the browser).

It is almost there but they are not centered:
http://londonlabs.co.uk/help/squares/

Any ideas?
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 12:34 PM Re: DIVs side by side not underneath?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Ok, you will need the overflow:auto on #boxWrap too to force it to contain the floated boxes inside it. That #boxWrap container WILL then center, however, at a width of 100%, it's not going to show as centered.

You can try putting like a 2% marign on the boxes themselves, it will space them out.

May I ask what you're putting in these boxes ??? You can't float AND center a div by itself, it's contradictory. Depending on what you're doing with it, you might have better luck using a list, and that is something that you CAN center.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 04:58 PM Re: DIVs side by side not underneath?
Ultra Talker

Posts: 316
Trades: 0
I've put the overflow on. Doesnt seem to have made a difference.

http://londonlabs.co.uk/help/squares/

I am going to put an image and some text in each one.

A list sounds good! How do I do that!?!

Thanks

Last edited by Joe3000; 04-01-2009 at 05:14 PM..
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2009, 11:31 PM Re: shopping cart cup holders
jesi's Avatar
Extreme Talker

Posts: 153
Trades: 0
Quote:
Originally Posted by paidginny View Post
Hello ppl,Let me introduce the best solution for ecommerce bend oregon ecommerce for smes bristol e-commerce solution cpa Have a look
You want to be banned ? Did not you read rules for posting ?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

jesi is offline
Reply With Quote
View Public Profile Visit jesi's homepage!
 
Old 04-02-2009, 01:21 AM Re: DIVs side by side not underneath?
Extreme Talker

Posts: 189
Trades: 0
New Idea

add
Code:
text-align-center;
to the wrapper to your original code.

add
Code:
display:inline-block;
to the box to your original code.

Last edited by simster; 04-02-2009 at 01:29 AM..
simster is offline
Reply With Quote
View Public Profile
 
Old 04-02-2009, 05:27 AM Re: DIVs side by side not underneath?
Ultra Talker

Posts: 316
Trades: 0
Quote:
Originally Posted by simster View Post
New Idea

add
Code:
text-align-center;
to the wrapper to your original code.

add
Code:
display:inline-block;
to the box to your original code.
Nearly! Works in FF but not IE(7).

Thanks.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 04-02-2009, 12:28 PM Re: DIVs side by side not underneath?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Unfortuntaely, IE has problems supporting the inline-block display property.
That's why I suggested a list.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 04-02-2009, 02:12 PM Re: DIVs side by side not underneath?
Ultra Talker

Posts: 316
Trades: 0
Thanks, I will take the hint!

Know of any good list tutorials?
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 04-03-2009, 09:50 AM Re: DIVs side by side not underneath?
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
This might help: http://accessat.c-net.us/test/gallery.html
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to DIVs side by side not underneath?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51058 seconds with 13 queries