Sunday, 15 August 2010

html - having difficulty in setting the text field to exact size -


I want to set my text field using the status: absolute so that it's in full width Parents div here is one for my question. I tried to do it with full, but in my browser the entire body was included and disappeared. I can also use width = 100% . What you can see I've used, but still the text field exits from the parent diva. Thanks in advance.

  div.middle_form_container {width: auto; Padding: 0px; Margin: 15px 10px; Border: Solid 1px red; } Div.middle_form_container & gt; Form {width: auto; Margin: 0px; Padding: 0px; } Div.sign_up_form_text {width: 100%; Display: inline-block; Margin: 0px; Margin-bottom: 0px; Padding: 0px; } Div.name {width: 48%; Margin: 0px; Margin-right: 0px; Swim left; Padding: 0px; Border: Solid 1px blue; } Div.first_name {margin-right: 12px; } .sign_up_form {status: relative; } .sign_up_form & gt; Input [type = text], sign_up_form & gt; Input [type = email], sign_up_form & gt; Input [type = password] {margin: 0x020px; Padding: 10px; Border: Solid 1px # 555; Border-radius: 6px; Font-family: "meridian suns"; Font-size: 19px; Profile: None; } Input.name {width: 100%; } Div.other_text_form {margin: 0 pixels; Padding: 0px; } Input.other_text {width: 100%; Margin: 0px; Padding: 0px; }    

padding, by default, outside width one Of element

So, assuming a div is the following CSS: width: 100px; Height: 100 pixels; Padding: 20px; Border: 1 px solid black; , the drawn range will be around 140x140px square.

This percentage also applies if the width: 100%; Padding: 20px; One box will make 100% PLUS 40px (2x20px) wide.

Therefore, you can avoid it from one of two ways:

  1. Account for padding in width (like width: 98%; padding: 1 % = 100% width)
  2. Box-Size: border-box; Property (width: 100%; padding: 10px; box-size: border-box; `= 100% width)

    Second option padding INSIDE Creates breadth in the form of illustrated: picture showing the effects of box-sizing < P> And they tell me this better.

    You must also include the vendor prefix:

      - moz-box-sizing: borderbox; -WebKit-box-size: border-box; Box-size: border-box;    

No comments:

Post a Comment