gpt4 book ai didi

asp.net-mvc - 将 Font Awesome 图标设置为文本框

转载 作者:行者123 更新时间:2023-11-28 16:34:25 25 4
gpt4 key购买 nike

我在将 i class 设置为文本框时遇到问题,我的实际观点是: enter image description here

我想要这样的东西:

enter image description here

我该怎么做?有我的代码( Razor ):

<div class="row">

<!-- feedback -->
<article class="feedback">
<div class="widget-title">Deja un mensaje </div>

@using (Html.BeginForm("Contact_Partial", "ContactModels", FormMethod.Post))
{

<h6>Campos Requeridos*</h6>
<br />

@*<div class="input-group">*@

<div class="col-md-9">
@*@Html.LabelFor(model => model.Name, "Nombre*", new { @class = "pull-left" })*@

<i class="fa fa-user appointment"></i> @Html.TextBoxFor(model => model.Name, new { @class = "form-control", @style = "width:100%", @placeholder = "Nombre*" })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })

</div>

<br />

<div class="col-md-9">
<i class="fa fa-envelope appointment"></i> @Html.TextBoxFor(model => model.Email, new { @class = "form-control", @style = "width:100%", @placeholder = "Email*", @type = "email" })

@Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })


</div>

<br />



<div class="col-md-9">

<i class=" fa fa-align-left appointment"></i>@Html.TextAreaFor(model => model.Comments, new { @class = "form-control", @style = "width:100%", @placeholder = "Mensaje*" })
@Html.ValidationMessageFor(model => model.Comments, "", new { @class = "text-danger" })
</div>

HTML 代码:

  <article class="feedback">
<div class="widget-title">Deja un mensaje </div>

<form action="/ContactModels/Contact_Partial/1" method="post"> <h6>Campos Requeridos*</h6>
<br />
<div class="col-md-9">


<i class="fa fa-user appointment"></i> <input class="form-control" data-val="true" data-val-required="Es necesario que ingrese su nombre" id="Name" name="Name" placeholder="Nombre*" style="width:100%" type="text" value="" />
<span class="field-validation-valid text-danger" data-valmsg-for="Name" data-valmsg-replace="true"></span>

</div>
<br />
<div class="col-md-9">
<i class="fa fa-envelope appointment"></i> <input class="form-control" data-val="true" data-val-required="Es necesario que ingrese su correo" id="Email" name="Email" placeholder="Email*" style="width:100%" type="email" value="" />

<span class="field-validation-valid text-danger" data-valmsg-for="Email" data-valmsg-replace="true"></span>


</div>
<br />
<div class="col-md-9">

<i class=" fa fa-align-left appointment"></i><textarea class="form-control" cols="20" data-val="true" data-val-minlength="Es necesario que ingrese al menos 10 caracteres" data-val-minlength-min="10" data-val-required="Ingrese algún comentario por favor" id="Comments" name="Comments" placeholder="Mensaje*" rows="2" style="width:100%">

                    <input type="submit" value="Enviar" class="btn button" /> 
</div>
</form>
</article>
</div>

AND CSS(如果我不用,也是一样的问题,图标出现在文字上方)

.widget-appointment {
display: none;
}

.widget-appointment i,i.appointment{
position:absolute;
z-index: 1;
top: 0;
left: 0;
width: 50px;
height: 50px;
font-size: 24px;
line-height: 50px;
text-align: center;
color: #fff;
}
i.appointment{
position:relative;
margin-right:5px;
margin-bottom:5px;
}
.widget-appointment i:after,i.appointment:after {
content: '';
position: absolute;
top: 50%;
left: 100%;
margin-top: -4px;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left-width: 4px;
border-left-style: solid;
}
.widget-appointment input,
.widget-appointment textarea {
height: 50px;
padding: 13px 10px 13px 65px;
}

.widget-appointment .captcha-wrapper input{
padding: 13px 6px;
}

.widget-appointment textarea {
height: auto;
}
.widget-appointment .row {
position: relative;
margin-bottom: -1px;
}

我不知道如何将 an 放入文本框区域,我认为这就是问题所在 所以,感谢您的阅读,非常感谢您的帮助

最佳答案

详细说明:首先去掉br标签,为i标签应用absolute class,为控制绝对位置应用一个relative div,

<div class="col-md-9">
<div class="relative">
<i class="fa fa-user appointment"></i>
<input type="text" value="" style="width:100%" placeholder="Nombre*" name="Name" id="Name" data-val-required="Es necesario que ingrese su nombre" data-val="true" class="form-control"/>
<span data-valmsg-replace="true" data-valmsg-for="Name" class="field-validation-valid text-danger"></span>

</div>

这里的CSS:

.relative{position:relative;}                
.appointment{position:absolute;}
input, textarea{padding-left:50px;}

关于asp.net-mvc - 将 Font Awesome 图标设置为文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30835707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com