标签旁边的文本框旁边的中心图像

时间:2013-01-08 19:33:33

标签: html css

到目前为止,我有this(img标签是由javascript添加的) enter image description here

HTML

<p class="pCalendarContainer">
  <label for="inputSearchTo" class="field" >To</label>
  <input id="inputSearchTo" name="inputSearchTo" type="text" class="textbox" />                
  <img class="ui-datepicker-trigger" src="../../images/calendar.gif" alt="..." title="...">
</p>

CSS

.pCalendarContainer
{

}
label.field
{
    text-align:left;
    width:100px;
    float:left;
    clear:both;/*forces fields under eachother in FF*/
}
input.textbox
{
    width: 150px;
    margin-left:20px;/*Always want at least 20 px between label and input*/
    float: left;
}
.pCalendarContainer > img
{
    margin-left:5px;
    float:left;
    width:20px;
    height:20px;
    vertical-align:middle;
}

Datepicker CSS供参考(默认不变)

.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
.ui-datepicker .ui-datepicker-prev { left:2px; }
.ui-datepicker .ui-datepicker-next { right:2px; }
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px;  }
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
.ui-datepicker select.ui-datepicker-month, 
.ui-datepicker select.ui-datepicker-year { width: 49%;}
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0;  }
.ui-datepicker td { border: 0; padding: 1px; }
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }

1 个答案:

答案 0 :(得分:1)

在图片上使用display:blockmargin-top

.pCalendarContainer > img
{
    margin-left:5px;
    float:left;
    width:20px;
    height:20px;
    display:block;
    margin-top:3px;    
}