1. 程式人生 > >input的樣式設定

input的樣式設定

<input>

輸入框:type=text

去掉輸入框的預設的樣式:

-web-kit-appearance:none;

-moz-appearance: none;

<input type="text" class="form_input" placeholder="請輸入姓名"/>

placeholder:隱式的顯示文字,當輸入內容後將消失。

<style>

input{

font-size:1.4em; 設定輸入框中字型的大小

height:2.7em; 設定輸入框的高度

border-radius:10px; 設定輸入框的圓角的大小

border:1px solid #c8cccf;設定輸入框邊框的粗細和顏色

color:#986655; 設定輸入框中文字的顏色

outline:0; 將輸入框點選的時候出現的邊框去掉

text-align:center; 設定輸入框中文字的位置

display:block; 將輸入框設定為塊級元素

}

</style>

input::-webkit-input-placeholder { /* WebKit browsers*/

  color:#999;font-size:14px;

  }

input:-moz-placeholder { /* Mozilla Firefox 4 to 18*/

  color:#999;font-size:14px;

  }

input::-moz-placeholder { /* Mozilla Firefox 19+*/

  color:#999;font-size:14px;

  }

input:-ms-input-placeholder { /* Internet Explorer 10+*/

  color:#999;font-size:14px;

}

這一段程式碼的作用是改變placeholder的預設樣式(顏色和字型大小)

按鈕:type=button

<input type="button" id="button" name=""/>

<style>

#button{

width: 186px;/*按鈕控制元件的寬度*/

/*text-align: center;按鈕控制元件中文字居中顯示*/

line-height: 500%;/*用百分比設定行高*/

padding-top: 0.1em;/*文字頂部的內邊距*/

padding-right: 2em;/*文字右側的內邊距*/

padding-bottom: 0.95em;/*文字底部的內邊距*/

padding-left: 2em;/*文字左側的內邊距*/

font-family: "Arial Black", Gadget, sans-serif;/*字型*/

font-size: 14px;/*字型大小*/

font-style: normal;/*字型樣式*/

font-variant: normal;/*小寫字母*/

font-weight: normal;/*文字不需要加粗*/

text-decoration: none;/*文字不需要下劃線等*/

margin-top: 0px;/*外邊框的距離*/

margin-right: 2px;/*外邊框的距離*/

margin-bottom: 0px;/*外邊框的距離*/

margin-left: 2px;/*外邊框的距離*/

vertical-align: text-bottom;/*影象放在文字下面*/

display: inline-block;/*段落內生出內框*/

cursor: pointer;/*滑鼠的形狀*/

zoom:1;

outline-width:medium;/*整個輪廓的寬度*/

outline-color:inherit;/*輪廓的顏色*/

font-size-adjust:none;

font-stretch:normal;

border-top-left-radius:1em;/*圓角邊框弧度*/

border-top-right-radius:1em;/*圓角邊框弧度*/

border-bottom-left-radius:0.5em;/*圓角邊框弧度*/

border-bottom-right-radius:0.5em;/*圓角邊框弧度*/

box-shadow:0px 1px 2px rgba(1,1,1,1.2);/*給按鈕增加陰影*/

color:#fef222;/*設定文字的顏色*/

border-top-color:#411c0c;/*邊框的顏色*/

border-right-color:#337c0c;/*邊框的顏色*/

border-bottom-color:#11110c;/*邊框的顏色*/

border-left-color:#da7c0c;/*邊框的顏色*/

border-top-width:5px;/*邊框的粗細*/

border-right-width:5px;/*邊框的粗細*/

border-bottom-width:5px;/*邊框的粗細*/

border-left-width:5px;/*邊框的粗細*/

border-top-style:solid;/*邊框的樣式*/

border-right-style:solid;/*邊框的樣式*/

border-bottom-style:solid;/*邊框的樣式*/

border-left-style:solid;/*邊框的樣式*/

background-image:none;/*背景圖片*/

background-attachment:scroll;/*背景圖片是否移動*/

background-repeat:repeat;/*允許重複*/

background-position-x:0%;/*背景的x軸座標*/

background-position-y:0%;/*背景的y軸座標*/

background-size:auto;/*背景圖片的尺寸*/

background-origin:padding-box;/*背景影象相對於內邊距框來定位*/

background-clip:padding-box;/*背景被裁剪到內邊距框*/

background-color:#f78d1d;/*背景顏色*/

}

</style>