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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:38:20+00:00 2026-06-17T01:38:20+00:00

This is a difficult question to put into words, so I think a practical

  • 0

This is a difficult question to put into words, so I think a practical demonstration is in order.

I have a collection of html elements:

<div class="outer-div">                  // Container
  <div class="content-div"></div>        // Text goes into this element
  <span class="clear-button"></span>     // BG image for this is a 16x16 icon
  <span class="select-button"></span>    // BG image for this is a 16x16 icon
</div>

Which uses this css:

div.select-div {
  background-color: white;
  border: 1px solid #CCC;
  vertical-align: middle;
  margin-bottom: 10px;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  height: 20px;
  padding: 4px 6px;
}

div.content-div {
  float: left;
  overflow: hidden;
  background-color: white;
  vertical-align: middle;
  font-size: 14px;
  color: #555;
  height: 20px;
  width: auto;
}

span.select-button {
  cursor: pointer;
  display: inline-block;
  float: right;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  position: relative;
  background-color: red; // for testing simplicity, this would be a bg image
}

span.clear-button {
  cursor: pointer;
  display: inline-block;
  float: right;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  position: relative;
  background-color: black; // for testing simplicity, this would be a bg image
}

Text is added into the content div, and works fine for a small amount of text e.g:

enter image description here

But if you add more text, this happens:

enter image description here

I’ve been tearing my hair out trying to find a way to stop those icons from ever moving from their positions, but I cant work it out. Ideally I’d like the div to expand vertically, but having the overflow text just be hidden would also be fine. the outer div width may vary.

  • 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-06-17T01:38:21+00:00Added an answer on June 17, 2026 at 1:38 am

    You can restrict the width of your content div and then use absolute positioning for the icons. That’s one method, but to explain your situation, you’re not defining a specific width for the content div or clearing the floats inside the container. That’s why things are breaking up. You can try something like this:

    div.select-div {
      background-color: white;
      border: 1px solid #CCC;
      vertical-align: middle;
      margin-bottom: 10px;
      -webkit-border-radius: 4px;
      -moz-border-radius: 4px;
      border-radius: 4px;
      height: 20px;
      width:200px;
      padding: 4px 6px;
      position:relative;
    }
    
    div.content-div {
      background-color: white;
      vertical-align: middle;
      font-size: 14px;
      color: #555;
      height: 20px;
      width: 160px;
    }
    
    span.select-button {
      cursor: pointer;
      display: inline-block;
      position:absolute;
      top:2px;
      right:38px;
      width: 16px;
      height: 16px;
      background-color: red; // for testing simplicity, this would be a bg image
    }
    
    span.clear-button {
      cursor: pointer;
      display: inline-block;
      width: 16px;
      height: 16px;
      position:absolute;
      top:2px;
      right:18px;
      background-color: black; // for testing simplicity, this would be a bg image
    }
    

    This should cause your container to expand vertically to fit the content. If that’s not desired, you can limit the height of the inner content and overflow hidden.

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

Sidebar

Related Questions

This is difficult for me to put into words, but say I have some
I'm finding this to be a difficult question to put into words, hence the
Apologies for the unweildy title, this is a very difficult question to put into
I'm finding it difficult to put the exact question into words, so I'll just
The title is a bit difficult to put together for this question. Say I
The background is in this question of mine. Put shortly, I have to fork
Ok, this is maybe a difficult question. And I don't want you to do
I know this question is difficult to understand but I need a mathematical equation
This seems like a simple question, but it is difficult to search for. I
This seems like a simple question, but has proven to be difficult to find

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.