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

  • SEARCH
  • Home
  • 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 193757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:32:15+00:00 2026-05-11T16:32:15+00:00

Im trying to think how to do this with html elements. There is nothing

  • 0

Im trying to think how to do this with html elements.

alt text

There is nothing special about the colors, so I don’t need to make them images.
Do note that the text is right aligned. Also, the color bar goes up to the text from the left.

So this could be implemented by having the text float right with background color white, and a div with the background color set right next to it (and then a clear).

Or instead of floats, I can do text align-right and get a similar effect.

Here is the kicker.

I’m using a javascript library (shouldn’t matter which one) to create an animation. The animation is the bars shrink to the left, and end up like so:

alt text

The problem with the float or text-align methods are that too many values have to be changed to transition between the two states. The javascript animation effects tend to want to change a couple predefined values, like width or font-size. In order to transfer from picture 1 to picture 2 using the float or text-align methods, I must remove the floating/text-align then set the width of the bar color, but that doesn’t work if I want to keep the javascript overhead minimal for such a simple task.

I’ve tried absolute positioning/widths, but I can’t get anything to make the text right aligned AND have the bars meet at the same point on the left.

I’m hoping maybe I’m just blind of a simple solution, but as I see it, I need one element that has the text positioned to the right somehow, and an element that takes up as much room possible beside it for the color… AND the element that has the color should be able to take a width, while having the text follow beside it.

Thank you.

  • 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. Editorial Team
    Editorial Team
    2026-05-11T16:32:15+00:00Added an answer on May 11, 2026 at 4:32 pm

    Here’s my attempt. Note: to the horror of some anti-table zealots this does use tables. Floats just can’t do “take up all available space” like tables can.

    <html>
    <head>
    <style type="text/css">
    table { width: 300px; background: #DDD; empty-cells: show; }
    th { padding-left: 8px; width: 100%; height: 1em; }
    td { padding-left: 12px; width: auto; }
    div { white-space: nowrap; }
    #row1 th { background: red; }
    #row2 th { background: blue; }
    #row3 th { background: green; }
    #row4 th { background: yellow; }
    #row5 th { background: pink; }
    #row6 th { background: gray; }
    </style>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.setOnLoadCallback(function() {
      $(function() {
        $("th").animate({ width: 0 }, 2000);
      });
    });
    </script>
    </head>
    <body>
    <table><tr id="row1"><th></th><td><div>FOO</div></td></tr></table>
    <table><tr id="row2"><th></th><td><div>BAR</div></td></tr></table>
    <table><tr id="row3"><th></th><td><div>THESE PRETZELS ARE</div></td></tr></table>
    <table><tr id="row4"><th></th><td><div>MAKING ME THIRSTY</div></td></tr></table>
    <table><tr id="row5"><th></th><td><div>BLAH</div></td></tr></table>
    <table><tr id="row6"><th></th><td><div>BLAH</div></td></tr></table>
    </body>
    </html>
    

    I thought of a non-tables way of doing it that works pretty well, so here it is:

    <html>
    <head>
    <style type="text/css">
    div div { height: 1.3em; }
    #wrapper { width: 300px; overflow: hidden; }
    div.text { float: right; white-space: nowrap; clear: both; background: white; padding-left: 12px; text-align: left; }
    #row1, #row2, #row3, #row4, #row5, #row6 { width: 270px; margin-bottom: 4px; }
    #row1 { background: red; }
    #row2 { background: blue; }
    #row3 { background: green; }
    #row4 { background: yellow; }
    #row5 { background: pink; }
    #row6 { background: gray; }
    </style>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.setOnLoadCallback(function() {
      $(function() {
        $("div.text").animate({ width: "90%" }, 2000);
      });
    });
    </script>
    </head>
    <body>
    <div id="wrapper">
    <div class="text">FOO</div><div id="row1"></div>
    <div class="text">BAR</div><div id="row2"></div>
    <div class="text">THESE PRETZELS ARE</div><div id="row3"></div>
    <div class="text">MAKING ME THIRSTY</div><div id="row4"></div>
    <div class="text">BLAH</div><div id="row5"></div>
    <div class="text">BLAH</div><div id="row6"></div>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • 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 It is not just about insertion and removal. You must… May 12, 2026 at 12:06 am
  • Editorial Team
    Editorial Team added an answer I think you're getting it with the correct encoding, it's… May 12, 2026 at 12:06 am
  • Editorial Team
    Editorial Team added an answer group_by is a great method: controller: def archive #this will… May 12, 2026 at 12:06 am

Related Questions

Is there anything similar to getElementById in actionscript? I'm trying to make a prototype
I'm trying to create a horizontal 100% stacked bar graph using HTML and CSS.
I'm making a webpage with dynamic content that enters the view with AJAX polling.
First of all let me say I'm not much of a design guy. Most

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.