gpt4 book ai didi

css - bootstrap form-inline 在一行中显示字段

转载 作者:太空宇宙 更新时间:2023-11-03 20:52:55 26 4
gpt4 key购买 nike

我希望我的登录表单将字段显示在一行中并排显示,而不是显示在彼此下方。

标题:

更新:此代码现在有效

<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<%= link_to "Apollo", root_path, id: "logo" %>
<nav>
<ul class="nav pull-right">

<%= form_for(:session, url: sessions_path, :html => { :class => "form-inline"}) do |f| %>
<input id="session_email" name="session[email]" type="text" class="input-medium" placeholder="Email">
<input id="session_password" name="session[password]" type="password" class="input-medium" placeholder="Password">
<button type="submit" class="btn btn-small btn-primary">Sign in</button>
<% end %>

</ul>
</nav>
</div>
</div>
</header>

生成的 HTML

<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a href="/" id="logo">Apollo</a>
<nav>
<ul class="nav pull-right">

<div class="row">
<div class="span2 offset3">
<form accept-charset="UTF-8" action="/sessions" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="xmS0FBX+pX8ZzBr/yHIUNmXOQMFI4krsv3FxIl51Hjg=" /></div>

<input id="session_email" name="session[email]" placeholder="Email" size="30" type="text" />

<input id="session_password" name="session[password]" placeholder="Password" size="30" type="password" />

<input class="btn btn-small btn-primary" name="commit" type="submit" value="Sign in" />

</form> </div>
</div>
</ul>
</nav>
</div>
</div>
</header>

自定义 CSS.SCSS

@import "bootstrap";

/* mixins, variables, etc. */

$grayMediumLight: #eaeaea;

@mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

/* forms */

input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
margin-bottom: 15px;
@include box_sizing;
}

input {
height: auto !important;
}

最佳答案

更改您的 CSS。

view 不是问题.

看起来你正在使用 Bootstrap ,所以将类 .form-inline 添加到表单中:

<%= form_for(:session, url: sessions_path, :html => { :class => "form-inline"}) do |f| %>

关于css - bootstrap form-inline 在一行中显示字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13897937/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com