我有这个代码:
<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 也会跳到下一行。
我怎样才能使它具有响应性,以便无论屏幕大小如何,按钮都保持在一行中?
最佳答案
添加.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/