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 6319297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:46:56+00:00 2026-05-24T15:46:56+00:00

I have two divs, inline. One displays a measurement, the other displays a unit

  • 0

I have two divs, inline. One displays a measurement, the other displays a unit value. The text in each is currently aligned correctly.

I would like to display a bar stretching across the top of the measurement value, but no further. Note: for various reasons, I can’t use text-decoration: overline. Instead I am trying to display a background image behind the text, clipping to the width of the text (not the div).

I have tried using display:table; on the measurement div, and this works, but it has the affect of screwing up my div layout (the text is not aligned between the divs).

Here’s some example html:

<div class="measurement">1234</div><div class="unit">mm</div>

Here’s some example css:

.unit {
  display:inline-block;
}
.measurement {
  display:inline-block;
  background-image:url(overline.png)
  width:200px;
  text-align: right;
}

Does anyone know of a way I can clip the background image to the width of the displayed text?

  • 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-24T15:46:56+00:00Added an answer on May 24, 2026 at 3:46 pm

    How about changing the divs to spans and wrapping the measurement span in a div to space it to the desired width?

    HTML:

    <div class="spacer"><span class="measurement">1234</span></div><span>mm</span>
    

    CSS:

    .spacer{
      width:200px;
      display: inline-block;
      text-align: right;
    }
    
    .measurement {
      background-image:url(overline.png);
    }
    

    See this jsFiddle for a working example.
    (background-color should work the same as an image).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two divs one floated to the left and the other to the
http://jsfiddle.net/pC6fC/1/ I have two divs, one above the other. When the first animates, which
I have two divs floated left so that they appear next to each other.
I have two divs. One of them contains an input field the other a
We have two DIVs, one embedded in the other. If the outer DIV is
I have two divs that are not nested, one below the other. They are
hey guys I have two divs- with id=form1 which is inline and the other
I have a table who's columns contain two inline divs, one displaying an image,
I have two divs. I would like to move/populate the text from div id
i have two divs with the same ids but one has display=none and the

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.