html - 如何使按钮在 Bootstrap 中响应?

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

我有这个代码:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" media="screen" /> 
        <style>
        .btn-file {
            position: relative;
            overflow: hidden;
        }
        .btn-file input[type=file] {
            position: absolute;
            top: 0;
            right: 0;
            min-width: 100%;
            min-height: 100%;
            font-size: 100px;
            text-align: right;
            filter: alpha(opacity=0);
            opacity: 0;
            outline: none;
            background: white;
            cursor: inherit;
            display: block;
        }
    </style>
    </head>
    <body>
        <div class="row" style="margin-top:10px; margin-bottom:10px;padding-bottom:40px;">
            <div class="col-md-6 col-md-offset-3 responsive">
                <button type="button" value="Btn1" class="btn btn-primary btn-sm" style="width:25%;background-color: #428bca;" disabled="disabled">Button1</button>
                <button type="button" value="Btn2" class="btn btn-primary btn-sm" style="width:25%;">Button2</button>
                <span class="btn btn-primary btn-file" style="font-size:12px;">File Upload button <input type="file" style="width:25%;"/>
                </span>
                <button type="button" value="Btn4" class="btn btn-primary btn-sm" style="width:25%;">Button4</button>
            </div>
        </div>
    </body>
</html>

这是 JSFiddle 的链接:https://jsfiddle.net/rvm49wfa/

正如您从下图中看到的那样,即使有一些空白,button4 也会跳到下一行。

enter image description here

我怎样才能使它具有响应性,以便无论屏幕大小如何,按钮都保持在一行中?

最佳答案

添加.nowrap{white-space: nowrap;}到你的 CSS

添加nowrap到这条线 <div class="col-md-6 col-md-offset-3 responsive nowrap">

参见 fiddle :https://jsfiddle.net/DIRTY_SMITH/rvm49wfa/4/

关于html - 如何使按钮在 Bootstrap 中响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34955272/

相关文章:

javascript - 未捕获的语法错误 : Unexpected end of input in html

jquery - TwitterBootstrap event.latedTarget() 不返回单击的按钮

javascript - Html5 和 Css 如何创建单独的 ul li 并将 <aside> 移到左侧

html - Firefox 正在缩小内联 block div 中的表格。这里发生了什么?

javascript - Safari 跳过网站标题并转到内容

css - HTML5 布局和页脚错误

javascript - 如何从 bootstrap-markdown 配置自动显示按钮?

javascript - Bootstrap 模态不透明度仅适用于特定的 div,不适用于整个 body

html - 添加样式如果元素有特定的兄弟

javascript - 检查输入是否未禁用且 jquery 不起作用