這讓我有點瘋狂,無法調整我添加到EditorFor文本框旁邊的圖形的期望寬度。MVC5在EditorFor旁邊添加glyphiconFor
我在下面我加旁EditorFor一個glyphicon的,請注意我最初把這是MVC5視圖模板生成的默認:
<div class="form-group">
@Html.LabelFor(model => model.ContactedDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10 input-group">
@Html.EditorFor(model => model.ContactedDate, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
<span class="btn btn-default input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
@Html.ValidationMessageFor(model => model.ContactedDate, "", new { @class = "text-danger" })
</div>
</div>
而且它看起來像這樣,注意glyphicon是那麼遠:
我後來改變到.col-md-4
這成爲下面:
還有一定距離,當我使用.col-md-3
,它將與箱重疊:
更重要的是,當我調整瀏覽器的寬度,glyphicon只會當我使用.col-md-4
或.col-md-3
時,移動到第一張屏幕截圖的位置,就像它不會緊挨着文本框。
我也在這裏檢查了這個question但它不幫助我。
如何正確添加圖形?
是否使用默認的ASP.NET MVC項目這裏是代碼的一部分,從我的項目
和調節日期模板?它有一個導致此問題的CSS規則。 –
是的,我想不出哪一個。 –
非常感謝@Tasos,您的評論只是給了我一個在網絡上的谷歌的想法,我發現它在這裏:https://roastlambda.wordpress.com/2014/08/29/fixing-wayward-input-groups -in-the-default-mvc5-bootstrap-template/ –