0

I can successfully center textbox in CSS. But the centered Textboxes are not aligned. How do I align them?

My html code:

  <div data-bind="dxList: { dataSource: dataSource}">
    <div data-options="dxTemplate : { name: 'item' } ">

        <div class="wrapper">
               <div data-bind="text: name" class="cls"></div>
            <input name="deneme" id="test" type="text"  />
        </div>
    </div>
</div>

Looks somewhat like this right now

enter image description here

3 Answers3

2

Notes: Using margin: 0 auto then horizontal align center element or Div

Method-1: Using display: flex;.

#test,
.test {
  margin: 0 auto;
  display: flex;
}
<div class="wrapper">
  <div data-bind="text: name" class="cls"></div>
  <input name="deneme" id="test" type="text" />
</div>

Method-2: Using display: block;

#test,
.test {
  margin: 0 auto;
  display: block;
}
<div class="wrapper">
  <div data-bind="text: name" class="cls"></div>
  <input name="deneme" id="test" type="text" />
</div>
Sumit patel
  • 3,807
  • 9
  • 34
  • 61
0

try with this css :

input {
   width:100px;
   display:block;
   margin:0 auto
}
Jishnu V S
  • 8,164
  • 7
  • 27
  • 57
vakho papidze
  • 465
  • 3
  • 12
0

Try it:- To center a div with margin: 0 auto; like suggested the div must contain a valid width.

If you add

#register{
 //...
 width: 300px;
 margin: 0 auto;
}

This will center your div in the center horizontally. You can also use text-align: center in the parent with display: inline-block in the form div. Such as:

#fg_membersite{
 text-align:center;
}

#register{
 display:inline-block;
}

If you want to center it also in the vertical i suggest you use display:table (on the aprent div) and display:table-cell (in a wrapper div) and vertical-align:middle options , or maybe a position:absolute with negative margins, it's your choice.

Razia sultana
  • 2,168
  • 3
  • 15
  • 20