html - 如何在 asp.net mvc5 中将图标放在输入标签内?

标签 html css asp.net

我是 asp.net mvc5 的新手。我试图将搜索图标放在搜索栏内,但它出现在栏外。任何人都可以告诉解决方案吗?这是快照和代码。 enter image description here

代码在这里..

    <div class="banner-g">
        <div class="container">
            <div id="user-info">
                <div class="navbar-form navbar-right">
                    <form action="/home/browse" id="searchForm" method="get">

                        <div class="inner-addon left-addon">
                            <a href="#" id="submitSearch" style="text-decoration: none; right: 14px; color: rgb(204, 204, 204); top: 6px; "> <i class="glyphicon glyphicon-search"></i></a>
                            <input class="form-control input-sm" data-val="true" data-val-length="The field Search must be a string with a maximum length of 150." data-val-length-max="150" data-val-regex="Please only use letters, numbers, spaces, periods, commas, question/ exclamation marks, dollar sign, underscores, hyphens, apostrophes, parentheses, forward and back slashes, colon and semi colons" data-val-regex-pattern="^[0-9a-zA-Z/&#39;() .,!?$:-;_-]+$" id="Search" name="Search" placeholder="Search Markets" type="text" value="" />
                            &nbsp;

                            <input type="hidden" name="isSearch" value="true">
                        </div>

                    </form>

                </div>
            </div>
        </div>
    </div>

在引导文件中

.glyphicon {
  position: relative;
  top: 1px;
  display: inline-block;
  font-family: 'Glyphicons Halflings';
  -webkit-font-smoothing: antialiased;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
}

我将感谢您的帮助。

最佳答案

您应该考虑使用 Bootstrap 输入组组件。您可以在文档中找到它 here .

像这样:

<div class="input-group">  
  <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
  <span class="input-group-addon glyphicon glyphicon-search" aria-hidden="true"></span>
</div>

这是一个demo .

关于html - 如何在 asp.net mvc5 中将图标放在输入标签内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40662206/

相关文章:

jquery - 在 HTML 页面中显示 XML 内容

c# - 在 asp.net 中将三个图像合并为一个图像

html - CSS 选择器冲突

javascript - 如何在 ASP.NET 网络表单上使用 javascript 设置文本框的值

html - Google Adsense 将整个页面向左移动

html - 响应式网站 : not scaling properly on mobile device

javascript - 添加作为链接添加到 BundleCollection 的 javascript 文件

c# - 如何设置 GridView EditItemTemplate 文本框采用最大单元格宽度?

javascript - 如何通过 jQuery 动态添加和删除元素?

php - 在文本区域输入字段中显示换行符