我對於其左側有圖標的輸入具有以下HTML結構。錶行寬度正在改變,以匹配不在表格行內的元素
<div class="fieldset">
<p>Normal Input</p>
<div>
<span><i class="icon-cart"></i></span>
<input name="">
</div>
</div>
我使用display:table
屬性的結構類型爲以下的圖像中表現出所需的佈局:根據標題
但是,圖標(<span>
)是拉伸它的寬度(<p>
),正如下圖所示:
這裏使用當前CSS:
/*Fieldsets*/
.fieldset {
width: 100%;
display: table;
position: relative;
white-space: nowrap;
margin-bottom: 15px;
}
.fieldset:last-of-type {
margin-bottom: 0;
}
/*Fieldsets > Labels*/
.fieldset > p {
width: 1%;
margin-bottom: 3px;
}
/*Fieldsets > Input Container*/
.fieldset > div {
display: table-row;
position: relative;
}
.fieldset > div > * {
display: table-cell;
white-space: nowrap;
vertical-align: middle;
position: relative;
}
/*Fieldsets > Input + Icon*/
.fieldset > div > span {
border: 1px solid #B0C2CE;
padding: 5px 15px;
font-weight: bold;
width: 1%;
}
/*Fieldsets > Input + Icon Senarios*/
.fieldset > div > span:first-of-type {
border-right: 0;
border-radius: 4px 0 0 4px;
}
.fieldset > div > span:not(:only-of-type) + input {
border-radius: 0;
}
.fieldset > div > input + span {
border-left: 0;
border-radius: 0 4px 4px 0;
}
.fieldset > div > span + input,
.fieldset > div > span + textarea,
.fieldset > div > span + select,
.fieldset > div > span + .select-dropdown-single .select-dropdown-input,
.fieldset > div > span + .select-dropdown-multi .select-input {
border-radius: 0 4px 4px 0;
}
/*Fieldsets > Input + Help ToolTip Icon*/
.fieldset > div [class^="tooltip-"],
.fieldset > div [class*=" tooltip-"] {
text-align: center;
width: 30px;
}
我怎樣才能阻止根據<p>
它上面改變圖標的寬度?甚至沒有包含在同一個Div內。
你不能給一個固定的寬度爲'.fieldset> div' – Abhi 2015-04-01 14:05:02