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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:05:27+00:00 2026-05-31T10:05:27+00:00

I have a div <div id=ab> which contain a text field <input type=text class=a

  • 0

I have a div <div id="ab"> which contain a text field <input type="text" class="a" /> and a submit button <input type="submit" value="Test" class="b" />. The div has fixed height and have length 100%. Text field have specific height. Submit button have specific height only. I want Text field to stretch the entire div (in width) leaving space for the submit button to dock. Setting width in percentage is not working;

styling;

#ab{
    background-color: #CCCCCC;
    width: 100%;
    height: 36px;
    border: solid 1px #999999;
}
#ab .a{
    display: block;
    float: left;
    border: none;
    height: 34px;
}
#ab .b{
    display: block;
    float: left;
    border: none;
    width: 100px;
    height: 36px;
}

html;

<div id="ab">
  <input type="text" class="a" />
  <input type="submit" value="Test" class="b" />
</div>

I am getting this;

enter image description here

and I want this;

enter image description here

Here is the fiddle.

How can I do this using css?

  • 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-31T10:05:29+00:00Added an answer on May 31, 2026 at 10:05 am

    The cleanest way to achiev this is giving #ab a fixed width. Then it’s pure math.

    Or you do this:

    #ab .a{
        width:100%; /* << */
        display: block;
        float: left;
        border: none;
        height: 34px;
    }
    #ab .b{
        margin: 0 0 0 -100px; /* << */
        display: block;
        float: left;
        border: none;
        width: 100px;
        height: 36px;
    }
    

    Additionally also apply box-sizing: border-box; to .a if you want its width to include optional paddings.

    .a { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div, which contains a text input field: <div id=age class=fullScreen> <input
I have a div which displays the current value of the slider and the
I have a div which opens when I click a menu button, I am
OK, so I have an internal div that is designed to contain text, images,
So I have a div which will contain 3 buttons and I want these
Q: I have a gridview which contains text box as a template field.The grid
I have a gridview which contains a text box as a template field.the grid
I have a jquery-ui-dialog that contains a <form> which contains a <input type=file >
I have a text field, which contains the default text 'abc' . When I
I have code sort of like this: <div class=right_col> <div class=right_box> <div class=other_div>text</div> text

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.