Skip to content Skip to sidebar Skip to footer

Visually Joining A Button And Text Field In Css

In a web forum I'm building (in Django/Python), one feature is that users can write a quick single line reply (tweet length) and then submit it for all participants to see. Current

Solution 1:

My technique to create something like that is to wrap both with a container

<div class="fancy-box-with-button">
  <input type="text"/>
  <button>Submit</button>
</div>

then move all your <input> styles to .fancy-box-with-button then make <input> transparent and other modifications as you see fit.

Make the button position: absolute and positioned right, add necessary padding-right to the parent element to prevent invisible input from being overlapped.

Most likely would look like this.

.fancy-box-with-button {
  background-color: white;
  border-radius: 4px;
  margin: 10px;
  display: block;
  position: relative;
  height: 30px;
  box-sizing: border-box;
  padding-right: 100px;
}

.fancy-box-with-button input {
  height: 100%;
  width: 100%;
  border: none;
  margin: 0;
  background-color: transparent;
}

.fancy-box-with-button button {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  height: 100%;
  width: 100px;
  border: none;
  color: white;
  background-color: blue;
}

working example


Solution 2:

Jsfiddle Demo
You should remove the width: 1000px since it will make the text field to wide, and it makes the text field not responsive.


Post a Comment for "Visually Joining A Button And Text Field In Css"