简体   繁体   English

使输入字段和响应

[英]make input fields and responsive

I have 3 element - input field, dropmenu and a button. 我有3个元素-输入字段,下拉菜单和一个按钮。 After few hours of trying, I still unable to place them in a row and responsive. 经过几个小时的尝试,我仍然无法连续放置它们并做出响应。 I used float but it seem to break when I resize the windows. 我使用了float,但在调整窗口大小时似乎断了。

<form>
    <div class="tasksInput">
        <input placeholder="Insert" type="text" class="form-control " />
    </div>
    <select>
        <option value="">Option</option>
    </select>
    <button type="submit" class="btn btn-primary">Submit </button>
</form>

http://jsfiddle.net/VgwL8/1/ http://jsfiddle.net/VgwL8/1/

FIXED DEMO 固定演示

I gave the input wrapper margin in is left side for both select and submit button. 我在选择和提交按钮的左侧都给出了输入包装边距。 and add wrapper to button + select + position absolute that relative to the form. 并将包装器添加到按钮+选择+相对于表单的绝对位置。

HTML 的HTML

<form>
    <div class="tasksInput">
        <input placeholder="Insert" type="text" class="form-control " />
    </div>
    <div class="submit-and-options">
        <select>
            <option value="">Option</option>
        </select>
        <button type="submit" class="btn btn-primary">Submit </button>
    </div>
</form>

CSS 的CSS

form{position:relative;}
.tasksInput{margin-right:150px;}
.submit-and-options{position:absolute; right:0; top:0;}

If you want a most flexible and modern solution you can use Flexbox model of CSS3, I have updated your jsfiddle DEMO HERE 如果您想要一个最灵活,最现代的解决方案,可以使用CSS3的Flexbox模型,我已经更新了您的jsfiddle DEMO HERE

using: 使用:

.flexBox {
    display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
    display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
    display: -ms-flexbox; /* TWEENER - IE 10 */
    display: -webkit-flex; /* NEW - Chrome */
    display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
    align-items: center;
    width: 100%;
}
.droptown {
    -webkit-box-flex: 1; /* OLD - iOS 6-, Safari 3.1-6 */
    -moz-box-flex: 1; /* OLD - Firefox 19- */
    -webkit-flex: 1; /* Chrome */
    -ms-flex: 1; /* IE 10 */
    flex: 1; /* NEW, */
    margin-right: 4px;
}
.flexChild {
    -webkit-box-flex: 2; /* OLD - iOS 6-, Safari 3.1-6 */
    -moz-box-flex: 2; /* OLD - Firefox 19- */
    -webkit-flex: 2; /* Chrome */
    -ms-flex: 2; /* IE 10 */
    flex: 2; /* NEW, */
    margin-right: 4px;
}

Use this... 用这个...

.tasksInput{
    display:inline;

}
.form-control
{
    display:inline;
width:100px;
}

hope it will help.. 希望对您有帮助。

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

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