I have limited website coding experience. I'm trying to implement bootstrap into my site, specifically by creating a navbar with it. It is working great except for when I lick the login button for the dropdown menu, the menu appears far too wide for the content. I used a css stylesheet to align the username and password forms to the right of the dropdown menu but there is still too much whitespace to the left of the forms.
For instance, I would much rather it trim down to the beginning of the 'newsletters' button.
Site can be found here: my_test_site
Code:
<li>Login <b class = "caret"></b>
<div class = "dropdown-menu dropdown-menu-right">
<div class="container">
<form class="form-inline" role="form" id="username">
<div class="form-group">
<label for="username">Username:</label>
<input type="username" class="form-control" id="email" placeholder="username">
</div>
<div class="form-group" id="password">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="password">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</li>
</ul>
The Class dropdown-menu has a min-width attribute.
min-width: 10rem;.
just override it with.
min-width: 1rem;
Here is a solution to the question of How to fix bootstrap menu into contents?
It doesnt use the single line format and reduce the whitespace specifically as requested, and heres why:
Even if you reduced the width of the dropdown panel containing the signin form , the form wasn't rendering properly in mobile view, e.g. you will see what I mean if you reduce the browser down to mobile size in your my_test_site demo, and then try to use the form .
How does my version work?
By changing bootstrap in the minimum way, my version works in both full width and mobile (as far I have tested anyway)
Also, I saw your CSS style rules and removed them - so there is really only bootstrap CSS + plus this inline style rule style="padding: 10px;" on the div wrapping your form
So basically
remove your style rules
Drop in the below code
Change the content of the code
And you should be go to go!
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<!-- Begin custom dropdown menu -->
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>
<!-- begin custom form -->
<div style="padding: 10px;"
<form class="form-inline" role="form" id="username">
<div class="form-group">
<label for="username">Username:</label>
<input type="username" class="form-control" id="email"
placeholder="username">
</div>
<div class="form-group" id="password">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="password">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<!-- end custom form -->
</li>
</ul>
</li>
<!-- Begin custom dropdown menu -->
</ul>
</div><!-- /.navbar-collapse -->
Here is a working demo - http://jsbin.com/lineketuru/1/edit?html,output
Related
Two things,
Nesting a form inside a menu item works except it hides again of the
mouse moves from the form div.
This form menu item is right aligned and the form left-most margin
is aligned with the left-most margin of the button so the actual
form flows beyond the window
<div class="home-menu pure-menu pure-menu-horizontal">
<a class="pure-menu-heading pure-menu-link" href="/">My Hip New Brand</a>
<ul class="pure-menu-list">
<li class="pure-menu-item">Blog</li>
<li class="pure-menu-item">Contact Us</li>
<li class="pure-menu-item">About</li>
</ul>
<ul class="pure-menu-list" style="float:right">
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">Sign In
<form action="/login" method="POST" class="pure-form pure-menu-children">
<fieldset class="pure-group">
<input name="username" type="text" placeholder="Username" class="pure-input-2-1" required/>
<input name="password" type="password" placeholder="Password" class="pure-input-2-1" required/>
</fieldset>
<button type="submit" class="pure-button pure-input-2-1 pure-button-primary">Sign In</button>
</form>
</li>
</ul>
</div>
EDIT: jsfiddle can be found here
I am creating a site using Bootstrap. I have one header, which includes the sites logo, I then want on the right of the container a search bar, aligned vertically in the header. My second header then has my link navigation stretching across the container.
I am having trouble adding the search bar, I tried to add it into a ul and pull to the right but it just went below my logo and full width.
Here is a bootsnip
http://bootsnipp.com/snippets/d393M
The mark up i am using for my search is
<div class="input-group">
<input type="text" class="form-control" placeholder="Search">
<span class="input-group-btn">
<button class="btn btn-info" type="button">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
Your link to the Bootsnip is not working so I can't look at it in more depth.
Try wrapping the search inside form tags as follows (this code from getbootstrap.com):
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
Try surrounding your form in a form element and adding the .navbar-form class to it.
I'm trying to create a menu where the login "username/password/sign in" buttons appear on the desktop site but in the mobile responsive version I jut want a "sign in" option that directs you to a sign in page.
I've used bootstrap-responsive.css to make the login-in boxes disappear when not in desktop, that works a treat but the "sign in" menu item will only either be responsive or look correctly formatted but not both
Here is the code
<span class="visible-phone visible-tablet" >
<li class="dropdown">
<li>
Sign in
</li>
</li>
</span>
<li class="dropdown visible-desktop">
<div class="form-group">
<form class="form-inline" role="form">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Enter email">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password">
<button type="submit" class="btn-u btn-u-default">Sign in</button>
<label><h6>Forgot Password?</h6></label>
</form>
</div>
</li>
This Will hide the menu in desktop view but display it in mobile/tablet view but the formatting is out, the form part of the code works perfectly
I changed the "visible-phone" and "visible-tablet" into two separate entries and that seems to have worked
<li class="dropdown visible-phone">
Sign in
</li>
<li class="dropdown visible-tablet">
Sign in
</li>
Ok, well you see I have been able to successfully create a dropdown login form in Twitter Bootstrap. In Bootstrap it was much simpler, but this framework doesn't work that easily. This is what I am trying to achieve: https://lh4.googleusercontent.com/-A1GH5oiWNEI/UTg6JoR9kDI/AAAAAAAAAAM/g4BJNVkvLJ4/s1600/Drop-Down-Form-F3.png. Here is my current code: (I cut some parts out)
<nav class="top-bar">
<ul class="title-area">
<!-- Title Area -->
<li class="name">
<h1>ChatAar</h1>
</li>
<!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
Login
<ul id="hover1" class="f-dropdown" data-dropdown-content>
<!-- Login form here -->
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<div class="red"><?php echo $Login; ?></div>
<p>Username:</p>
<input name="user" type="text" class="field" id="user"/>
<p>Password:</p>
<input name="pass" type="password" class="field" id="pass" value="" />
<br />
<label style="text-color:white;">Remember Me For 30 Day's</lable>
<input name="remember" type="checkbox" value="true" />
<input name="page" type="hidden" value="<? echo $_GET['page']; ?>" />
<input name="submit" type="submit" class="button" value="Log In" />
<br />
Password Recovery | Sign Up
</div>
</form>
</ul>
</ul>
</section>
</nav>
And this is what I get:
http://webymaster.hj.cx/public.php?service=files&t=cdf517da96a2ad178045198169958afb. I have tried normal drop downs but it doesn't work (sorry dont have a pic) then I came up with this but, its not the best. Please Help Thank You!
Using Foundation 5, this will get you close:
<nav class="top-bar" data-topbar>
<section class="top-bar-section">
<ul class="right">
<li>Sign In</li>
</ul>
</section>
</nav>
<div id="signin" class="f-dropdown small content" data-dropdown-content>
<!-- signin form here -->
</div>
Note that the login form needs to be located outside of the top-bar, otherwise it will have badly mangled styles.
For a complete reference, examples, and ideas of how to customize it, check out Zurb's wonderful documentation on dropdowns and forms.
Expanding on chadoh's excellent answer, for anyone who's looking for something simple and ready to go:
<div id="login-dropdown" class="f-dropdown small content" data-dropdown-content="true">
<h5>Log In:</h5>
<form id="top-nav-login" action="login.xqy" method="post">
<div class="row">
<label>Email Address</label>
<input type="email" name="email" placeholder="email#example.com" tabindex="1"/>
</div>
<div class="row">
<label>Password</label>
<input type="password" name="email" placeholder="********" tabindex="2"/>
</div>
<div class="row">
<input type="submit" class="button tiny success" value="Login" tabindex="3"/>
</div>
</form>
</div>
This is just the dropdown part of the markup. You'll still need the top-bar and data-dropdown element from chadoh's answer. Obviously add your own form elements as needed.
I have a dropdown in bootstrap, but I don't know how to center a form I have within it.
Here is my code;
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Testing, 123</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><i class="icon-home icon-white"></i> Home</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<div class="dropdown-menu">
<form accept-charset="UTF-8" action="/sessions" method="post">
<fieldset class='textbox login'>
<label id='js-username'>
<span>Username</span>
<input autocomplete="on" id="username" name="username" type="text" size="20px"/>
</label>
<label id='password'>
<span>Password</span>
<input id="userpassword" name="userpassword" type="password" />
</label>
</fieldset>
<fieldset class='subchk'>
<input name="commit" type="submit" value="Log In" />
</fieldset>
</form>
</div>
</li>
</ul>
<form class="navbar-search pull-right" action="">
<input type="text" class="search-query span2" placeholder="Search">
</form>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar -->
I have adjusted the width of the dropdown in the css to fit my form, I just can't work out how to center the form within the dropdown.
Without seeing your CSS it's hard to say for sure that this will work, but try this:
.dropdown-menu form {
width: *insert form width here in pixels*;
margin: 0 auto;
}
This answer assumes that the li with the class dropdown is bigger horizontally than your form, and you are trying to center the form within it. To center something horizontally using this method it must have a fixed width, and the width must be smaller than the parent element (in this case the li with the class dropdown).
Edited to add: I didn't realize how old this question was until after I answered it..
Just create a class with some padding and add it to your form tag, like so:
CSS
.wrap {
padding:15px;
}
HTML
<form class="wrap" accept-charset="UTF-8" action="/sessions" method="post">...</form>
Demo: http://jsfiddle.net/a52UY/
use center tag it might be help to you
<center> </center>
<div class="dropdown-menu">
<center>
<form accept-charset="UTF-8" action="/sessions" method="post">
.......
</form>
</center>