Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 154871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:03:21+00:00 2026-05-11T10:03:21+00:00

How can I get the right floating DIVs to fill their available space? .content{

  • 0

How can I get the right floating DIVs to fill their available space?

        .content{             background-color: #fff;             margin: 0px auto;             width: 760px;             border: 1px solid blue;             font-size: 10pt;         }          .content .leftSide {             background-color: yellow;             float: left;             padding: 5px;         }          .content .rightSide {             background-color: orange;             float: left;             width: *;             padding: 5px;             text-align: center;         }
<div class='content'>          <div class='leftSide'><img src='test.jpg'/></div>         <div class='rightSide'>Right side text should be centered.</div>         <div style='clear:both'></div>  </div>  <div class='content'>         <div class='leftSide'><img src='test2.jpg'/></div>         <div class='rightSide'>And the background should fill the DIV of course.</div>         <div style='clear:both'></div>          </div>

INTERMEDIATE ANSWER:

Thanks Guffa and Rich, taking float:left off the right side allowed the text to be centered, but to get the background color to extend down, I had to also make the background color of the parent DIV.

However, I still can’t get the text to align in the middle vertically since the DIV doesn’t actually go all the way down, is there an ‘auto’ for that too? e.g. height:*, or float-down:auto? As Cletus mentioned below, this would all be trivial in HTML tables, the CSS designers surely included some property to ‘make the vertical space fill downward’.

alt text http://tanguay.info/web/external/cssRightFixed.png

.content{           background-color: orange;           margin: 0px auto;           width: 760px;     			border: 1px solid blue;     			font-size: 10pt;     		}     		     		.content .leftSide {     			background-color: yellow;     			float: left;     			padding: 5px;     		}     		     		.content .rightSide {     			background-color: orange;     			padding: 5px;     			text-align: center; 			    vertical-align: middle;     /* DOESN'T WORK SINCE THE DIV DOES       NOT ACTUALLY GO ALL THE WAY DOWN */     		}
<div class='content'>     		<div class='leftSide'><img src='test.jpg'/></div>     		<div class='rightSide'>Right side text should be centered.</div>     		<div style='clear:both'></div>     	</div>     	<div class='content'>     		<div class='leftSide'><img src='test2.jpg'/></div>     		<div class='rightSide'>And the background should fill the DIV of course.</div>     		<div style='clear:both'></div>     	</div>     	<div class='content'>     		<div class='leftSide'><img src='test3.jpg'/></div>     		<div class='rightSide'>And the background should fill the DIV of course.</div>     		<div style='clear:both'></div>     	</div>     	<div class='content'>     		<div class='leftSide'>this is a text on the left with no image</div>     		<div class='rightSide'>And the background should fill the DIV of course.</div>     		<div style='clear:both'></div> </div>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:03:21+00:00Added an answer on May 11, 2026 at 10:03 am

    If you use floats, you pretty much need to give them widths. Floats are fine if you specify the width or you’re happy with whatever the browser calculates as the minimum required width. As soon as you need them to expand to fill available space you’re out of luck.

    In fact you’re using the wrong tool.

    So you have two possibilities:

    1. Fix the size of the floats; or
    2. Use a table.

    With tables this is a trvial problem to solve (waits for the anti-table pure-CSS fanatics to go nuts).

    EDIT: Ok, you want to do verticall centering as well. Now you’re really in trouble. See Can you do this HTML layout without using tables? for how hard even simple layout can be with pure CSS, particularly when you want to do vertical centering (when the container or the child aren’t fixed height) or side by side content.

    Again, tables make this trivial with vertical-align: middle.

    If you want more information on vertical centering with pure CSS, see:

    • Vertical Centering in CSS: three levels of nested divs… just to get vertical centering;
    • How to: vertical centering with CSS; and
    • Vertical centering with CSS.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 127k
  • Answers 127k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're probably looking at doing something with includes, which isn't… May 12, 2026 at 5:32 am
  • Editorial Team
    Editorial Team added an answer To answer the second question, if you control both malloc/free… May 12, 2026 at 5:32 am
  • Editorial Team
    Editorial Team added an answer The feature you're looking for are custom actions. They allow… May 12, 2026 at 5:32 am

Related Questions

Mark Up <%@ Page Language=C# AutoEventWireup=true CodeBehind=test.aspx.cs Inherits=Zuhaib.test %> <!-- Put IE into quirks
I want my website to join some webcam recordings in FLV files (like this
Im trying to think how to do this with html elements. There is nothing
It's been quite a while since I last used D Programming Language , and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.