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
Is it possible to float two divs side-by-side without setting width?
Old 03-24-2011, 10:25 PM Is it possible to float two divs side-by-side without setting width?
Super Talker

Posts: 113
Trades: 0
I'm trying to put two divs side by side. I want the div on the right to take up as much room as it needs (php echos code for an image in this div, so the width needs to be variable for images of different widths) and the one on the left to take up whatever room is left. I can't get it to work without setting the width of the left div in advance, though. Is what I'm asking possible?
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-25-2011, 10:01 AM Re: Is it possible to float two divs side-by-side without setting width?
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
HTML Code:
<div style="width:400px; float:left; background:#00ee00;"> 
<div style="width:100px; float:right; background:#ee0000;"> 
fixed
</div>
<div style="display:block; margin-left:auto; margin-right: auto; background:#0000ee;"> 
XXXXX
</div>
</div>
__________________

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


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 03-25-2011, 10:39 AM Re: Is it possible to float two divs side-by-side without setting width?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If you float an element without a set width it will be as wide as the longest horizontal line of content plus left and right padding.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Is it possible to float two divs side-by-side without setting width?
 

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.32031 seconds with 12 queries