html - 在 bootstrap 3 中自定义输入组内的输入框和按钮宽度

标签 html css twitter-bootstrap twitter-bootstrap-3

<分区>

我有一个这样的搜索框

enter image description here

代码

<div class="input-group">
     <input name="search" value="" class="form-control" placeholder="Search" type="text" >
     <span class="input-group-btn">
        <button class="btn btn-default" type="submit"><span class="icon-search"></span></button>
     </span>
</div>

此处搜索框为 100%。

我想自定义搜索框和搜索按钮的大小 80% 和 20%

其实我想把我的搜索框做成那样 enter image description here

有伊迪亚吗?

最佳答案

纯 CSS。

#search-form .form-control,
#search-form .form-control:focus,
#search-form .form-control:hover {
  height: 50px;
  border-right: none;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  outline: none;
  box-shadow: none;
  left: 20px;
  margin-top: -1px;
}
/**/

#search-form button.btn.btn-orange,
#search-form button.btn.btn-orange:hover,
#search-form button.btn.btn-orange:focus {
  position: relative;
  height: 50px;
  width: 175px;
  color: white;
  background: none;
  font-size: 20px;
  text-align: left;
  margin-left: 15px;
  outline: none;
  box-shadow: none;
  border: none;
}
#search-form button.btn.btn-orange:before,
#search-form button.btn.btn-orange:after {
  position: absolute;
  content: '';
  top: -1px;
  height: 50px;
  width: 55%;
  background: #DC521F;
  z-index: -1;
}
#search-form button.btn.btn-orange:before {
  left: -15px;
  border-radius: 0;
  border-right: none;
  transform: skew(20deg);
  transform-origin: top left;
}
#search-form button.btn.btn-orange:after {
  right: 0px;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  border-left: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<hr>
<form id="search-form">
  <div class="container">
    <div class="input-group">
      <input type="text" class="form-control" placeholder="Search for..."> <span class="input-group-btn">
                <button class="btn btn-orange" type="button">
                    <span class="glyphicon glyphicon-search">
                    </span>

      </button>
      </span>
    </div>
  </div>
</form>
<hr>

关于html - 在 bootstrap 3 中自定义输入组内的输入框和按钮宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32602035/

相关文章:

javascript - 如何避免网站其他部分出现 jQuery 移动样式?

javascript - HTML5 原生拖放中的克隆阴影

css - Bootstrap 中的断字不起作用

javascript - Bootstrap 3 选项卡和 Chart.js - 图表未加载到选项卡上

html - 将 .panel 与 FIELDSET 和 .panel-heading 与 LEGEND 组合时的设计问题

css - 如何引用作为gradle依赖项下载的bootstrap的CSS?

html - div 不显示背景

javascript - 如何使框的底部在 FullCalendar 中的新元素的 'append' 上移动

css - 在移动设备上查看时如何隐藏我的菜单?

html - 为什么会出现 "Prefix h for element h:head is not bound"错误?