html - 按钮旁边的 Bootstrap 对齐文本框出现问题

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

我正在尝试构建我在图像中附加的内容,但不幸的是我无法正确放置它,到目前为止这是我的 HTML(我是 bootstrap 的新手)

<div class="row">
  <div class="container">
    <div class="col-lg-3">
    </div>
    <div class="col-lg-6">
        <p class="text-center">
            <strong>Enter your email and get special information</strong>
        </p>
        @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @class = "form-inline col-lg-12" }))
        {
            <div class="input-group col-lg-9" style="margin-left: 3%">
                <input type="text" class="form-control">
            </div>
            <div class="input-group col-lg-2">
                <button class="btn btn-primary">Submit</button>
            </div>
        }
    </div>
    <div class="col-lg-3">

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

应该是这样的

enter image description here

但看起来像这样,理想情况下我希望按钮更靠近文本框

enter image description here

但是当我在手机屏幕上查看时,我发现一团糟

enter image description here

如有任何帮助,我们将不胜感激。

最佳答案

这个 fiddle 怎么样:

http://jsfiddle.net/jwyr6Lwh/1/

    .custom input.form-control {
        border: 1px solid #848484; 
        -webkit-border-radius: 30px !important; 
        -moz-border-radius: 30px !important; 
        border-radius: 30px !important;
        -moz-box-shadow: 2px 2px 1px #666;
        -webkit-box-shadow: 2px 2px 1px #666;
        box-shadow: 2px 2px 1px #666;
        outline:0; 
        padding-left:10px; 
        padding-right:0px; 
        background-color: rgba(255,255,255,0.2);

    } 

    .custom  button {
        -webkit-border-radius: 20px;
        -moz-border-radius: 20px;
        border-radius: 20px;
    }

它在移动浏览器上显示不同的原因是它的响应能力

class="col-lg-2"

意味着在大型设备上它将显示在两列中,否则一列显示在另一列之下。如果您不打算这样做,请选择 class="col-sg-2"。

enter image description here

关于html - 按钮旁边的 Bootstrap 对齐文本框出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27934254/

相关文章:

javascript - 如何为 div 内的 span 元素添加摇动动画

javascript - 根据输入的字符数更改字体

jquery - 我如何在 jquery 中切换点击功能

javascript - Chrome 中 div 下方的空白,但 Firefox (HTML5) 中没有

jquery - 如何通过KO的绑定(bind)方法更改表格行背景颜色?

html - 固定宽度容器内的行内 block 元素

jquery - 模态下方的下拉内容

javascript - bootstrap modal 显示先前调整大小的 textarea

html - 如何让我的图像相对于左侧的动态 div 在中心垂直对齐?

javascript - 使用 ng-click 单击其他按钮时按钮颜色发生变化