html - 附加图像时如何使边框在 Bootstrap 的输入组中保持一致?

标签 html css bootstrap-4

我想在导航栏中创建一个搜索框,我得到了这样的效果:

search box with bad border

所以我的问题是我无法使边框保持一致 - 我希望图标与“搜索...”框具有相同的边框,并且它们之间没有边框。

它的代码如下所示:

<div class="input-group" style="width: 10rem;">
<input type="search" placeholder="Search..." aria-describedby="button-addon5" class="form-control">
<div class="input-group-append">
    <button id="button-addon5" type="submit" class="btn" style="background-color: White;">
        <svg class="bi bi-search" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="color: rgb(230,0,0);">
          <path fill-rule="evenodd" d="M10.442 10.442a1 1 0 011.415 0l3.85 3.85a1 1 0 01-1.414 1.415l-3.85-3.85a1 1 0 010-1.415z" clip-rule="evenodd"/>
          <path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 100-11 5.5 5.5 0 000 11zM13 6.5a6.5 6.5 0 11-13 0 6.5 6.5 0 0113 0z" clip-rule="evenodd"/>
        </svg>
    </button>
</div>

我最接近解决它的方法是查找 bootstrap 的 css 并将边框属性复制到按钮元素,然后将 border-left 设置为无,但是尽管没有左边框,但圆 Angular 还是可见的问题。即使可以删除左边的 Angular ,我觉得一定有更好的方法......:/

最佳答案

在按钮上使用边框工具...

   <div class="input-group" style="width: 10rem;">
        <input type="search" placeholder="Search..." aria-describedby="button-addon5" class="form-control">
        <div class="input-group-append">
            <button id="button-addon5" type="submit" class="btn border-left-0 border" style="background-color: White;">
                <svg class="bi bi-search" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="color: rgb(230,0,0);">
                    <path fill-rule="evenodd" d="M10.442 10.442a1 1 0 011.415 0l3.85 3.85a1 1 0 01-1.414 1.415l-3.85-3.85a1 1 0 010-1.415z" clip-rule="evenodd" />
                    <path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 100-11 5.5 5.5 0 000 11zM13 6.5a6.5 6.5 0 11-13 0 6.5 6.5 0 0113 0z" clip-rule="evenodd" />
                </svg>
            </button>
        </div>
   </div>

演示:https://codeply.com/p/wLgphISgj2

关于html - 附加图像时如何使边框在 Bootstrap 的输入组中保持一致?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60773319/

相关文章:

javascript - 从 2 组单选按钮获取 url

jquery - 删除和添加宽度时元素不断变化

javascript - 当弹出框指令工作时,什么会导致弹出框组件失败

html - 导航中的线性渐变不显示

jquery - 使用 JQuery 构建选项卡

javascript - 在 JSONP 结果中设置 sessionStorage?

.net - 如何将 ASP.NET Treeview 控件绑定(bind)到数据表?

javascript - Chrome 应用评论区

css - 如何根据页面高度调整文本大小?

html - 在线 CSS 优化器?