简体   繁体   English

Twitter引导程序:减小页面大小时,输入字段会占用太多空间

[英]Twitter bootstrap: Input fields taking up too much space when page size is reduced

Here's a jsfiddle http://jsfiddle.net/R5TB2/ 这是一个jsfiddle http://jsfiddle.net/R5TB2/

code is in the fiddle :)

Whenever the page size gets reduced so that the input fields get put below the labels, the input fields get immensly large! 每当页面大小减小从而将输入字段放置在标签下方时,输入字段就会变得非常大! I might have some serious bootstrap knowledge gaps here, but I can't, for the life of me, see what's causing this! 我可能在这里存在一些严重的自举知识鸿沟,但是我一生都无法看到是什么原因造成的!

Any suggestions? 有什么建议么? I've tried all the margin: 0 auto etc., and it didn't work. 我已经尝试了所有的余量:0自动等,并且它没有用。 And I'd like to get this to work without any 'hacks' ^^ 我想在没有任何“ hacks”的情况下使它工作^^

Thanks! 谢谢!

I suggest you read up on how bootstrap grid layout works. 我建议您阅读有关引导网格布局如何工作的信息。

Your problem is this, col-md-5 你的问题是这个, col-md-5

As soon as your screen is below this md size, the bootstrap class doesn't apply, and thus the width resorts to it's default size, auto, which stretches it to fit it's parent container. 一旦您的屏幕低于此md大小,bootstrap类将不适用,因此,宽度将诉诸于其默认大小auto,它将自动扩展以适合其父容器。

You should be using xs 您应该使用xs

Fiddle : http://jsfiddle.net/R5TB2/1/ 小提琴: http : //jsfiddle.net/R5TB2/1/

You have to change the BT class : 您必须更改BT类:

col-md-* to col-xs-* col-md-*col-xs-*

Extract : Change 摘录:更改

<label class="col-md-5 control-label" for="username">Username:</label>
    <div class="col-md-2">
        <input id="username" class="form-control" type="text" placeholder="Username.." />
    </div>

to

<label class="col-xs-5 control-label" for="username">Username:</label>
    <div class="col-xs-2">
        <input id="username" class="form-control" type="text" placeholder="Username.." />
    </div>

Here is the doc : http://getbootstrap.com/css/#grid 这是文档: http : //getbootstrap.com/css/#grid

UPDATE AFTER COMMENT 评论后更新

Look this fiddle : http://jsfiddle.net/9URh5/ 看这个小提琴: http : //jsfiddle.net/9URh5/

You can add class for each devise 您可以为每个装置添加类

UPDATE AGAIN : 再次更新:

When you resize windows, look this native class : 调整窗口大小时,请查看以下本机类:

@media (min-width: 768px)
.form-horizontal .control-label {
text-align: right;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM