I have a Dropdown in my TopBar, built with the Twitter Bootstrap CSS framework.
I have 3 problems with it that I can't find any solution to:
The text and password input fields are far too big, how can I adjust them? Making the dropdown box bigger would be OK too.
The labels for the fields are too dark, how can I lighten them up a bit?
The Dropdown is closing when I click into one of the fields. I have to reopen it and then I can type until clicking in the next field. The values are preserved even when the dropdown is closed. How can I make it stay open?
Here is a screenshot of problems 1 and 2:
Also here is the HTML for the TopBar as it is now.
<div class='topbar-wrapper'>
<div class='topbar'>
<div class='topbar-inner'>
<div class='container'>
<h3>
Webworld
</h3>
<ul class='nav'>
<li>FILLER...</li>
</ul>
<ul class='nav secondary-nav'>
<li class='dropdown' data-dropdown='dropdown'>
Login
<div class='dropdown-menu' id='signin-dropdown'>
<form accept-charset="UTF-8" action="/sessions" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="4L/A2ZMYkhTD3IiNDMTuB/fhPRvyCNGEsaZocUUpw40=" /></div>
<fieldset class='textbox'>
<label id='js-username'>
<span>Username</span>
<input autocomplete="on" id="username" name="username" type="text" />
</label>
<label id='password'>
<span>Passwort</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>
</div>
</div>
</div>
</div>
There hidden input is needed by rails and autogenerated.
I've already tried to copy the implementation of the login form that twitter uses, but when I tried that, the TopBar is about 250px in height and the content of the dropdown is open, not closeable.
I have no custom CSS or JavaScript so far, except for the top-padding of 40px in the body as suggested by the bootstrap docs.
Can someone help me with this?
Try adding the code below somewhere in your javascript. It should stop it from happening.
$('.dropdown-menu').find('form').click(function (e) {
e.stopPropagation();
});
(Twitter Bootstrap 2.x)
You may want to move the contents of style="" to your stylesheets...
If user entered wrong password:
add class open to li class="dropdown open"
and class error to fieldset class="control-group error"
<ul class="nav pull-right">
<li class="dropdown">
Login <b class="caret"></b>
<div class="dropdown-menu">
<form action="" id="form_login" style="margin: 0; padding: 3px 15px" accept-charset="utf-8" method="post">
<fieldset class="control-group">
<label for="form_email" class="control-label">Email address</label>
<div class="controls">
<div class="input-prepend" style="white-space: nowrap">
<span class="add-on"><i class="icon-envelope"></i></span>
<input type="email" name="email" id="form_email" autocomplete="on" class="span2">
</div>
</div>
</fieldset>
<fieldset class="control-group">
<label for="form_password" class="control-label">Password</label>
<div class="controls">
<div class="input-prepend" style="white-space: nowrap">
<span class="add-on"><i class="icon-lock"></i></span>
<input type="password" name="password" id="form_password" class="span2">
</div>
</div>
</fieldset>
<label class="checkbox">
<input type="checkbox" name="remember" value="true"> Remember me
</label>
<p class="navbar-text">
<button type="submit" class="btn btn-primary">Login</button>
</p>
</form>
</div>
</li>
</ul>
You don't need any extra css or javascript to make this look nice (with TB2.x)
In case you don't want to stop propagation of your events, or that solution didn't work for you, you can add this code somewhere near initialization of bootstrap-dropdown:
$('html').off('click.dropdown.data-api');
$('html').on('click.dropdown.data-api', function(e) {
if(!$(e.target).parents().is('.dropdown-menu form')) {
$('.dropdown').removeClass('open');
}
});
For your third question - In your bootstrap-dropdown.js comment source code row
$('html').on('click.dropdown.data-api', clearMenus)
and write there this:
$(document).bind('click', function(e) {
var $clicked = $(e.target);
if (!$clicked.hasClass("dropdown-menu") &&
!$clicked.parents().hasClass("dropdown-menu")){
clearMenus();
}
});
https://github.com/twitter/bootstrap/blob/master/bootstrap.css#L1559
max-width is set to 220px, remove the attribute and it will stretch itself.
Its looks like a CSS based problem u are facing.
I fixed it with the following styles:
#signin-dropdown {
padding-left: 5px;
padding-right: 5px;
padding-top: 1em;
}
#signin-dropdown form {
margin:0px;
}
#signin-dropdown form .textbox {
margin-bottom:0em;
padding-top:0em;
}
#signin-dropdown form .subchk {
margin-bottom: 5px;
padding-top: 8px;
}
#username, #password, #userpassword {
color: #404040;
float: left;
font-size: 13px;
line-height: 18px;
padding-top: 0px;
text-align: left !important;
width: 140px;
}
About your questions 1 and 2.
Have you tried setting the length of the input? You can do this by setting the "size" attribute of the input tag. You can read more here
Did you try changing the style of the label? For example:
<span style="color:#FFFFFF">Username </span>
you just add your content in <form></form> tag
like this:
<div class="dropdown dropdown-scroll" id="selectedClient">
<button class="btn btn-block btn-lg btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
انتخاب <span class="caret"></span>
</button>
<div class="dropdown-menu " role="menu" aria-labelledby="dropdownMenu1">
<button type="button" class="close">×</button>
<form>
<ul>
<li role="presentation">
<input id="searchSubClientInput" type="text" class="form-control" placeholder="جستجو بر اساس نام خانوادگی" ng-model="query">
</li>
</ul>
</form>
<ul class="select-list scrollable-menu">
<li class="dropdown-header">خودم</li>
</ul>
</div>
</div>
Related
function displayEditProfileStudent() {
document,getElementById('editstudentprofile').setAttribute('class', 'unhide');
document.getElementById('profile_viewStudent').setAttribute('class', 'hide');
document.getElementById('ViewStudent').setAttribute('class', 'unhide');
}
function displayProfileViewStudent() {
document,getElementById('editstudentprofile').setAttribute('class', 'hide');
document.getElementById('profile_viewStudent').setAttribute('class', 'unhide');
document.getElementById('ViewStudent').setAttribute('class', 'unhide');
}
<div id="ViewStudent" class="hide">
<a href="#ViewProfileStudent" class="student_profile_view col-sm-1" onclick= "displayProfileViewStudent()" >View Profile</a>
Edit Profile
<form id="editstudentprofile" class="hide">
<h4>Edit Profile</h4>
<label class="col-sm-3">Major:</label>
<input class="major_input col-sm-5" name="studentmajor" type="text" placeholder="Enter your Major">
<br/>
<label class="col-sm-3">Cumulative GPA:</label>
<input class="GPA_input col-sm-1" name="studentGPA" type="text" placeholder="GPA">
<br/>
<label class="col-sm-3">Expected Graduation Date:</label>
<input class="graduation_input col-sm-2" name="studentgraduationdate" type="text" placeholder="MM/DD/YYYY">
<br/>
<label class="col-sm-3">Have you served as a TA before?</label><br/>
<input class="previousTA_input" name="previousTA" type="radio"> Yes<br/>
<input class="previousTA_input" name="previousTA" type="radio"> No<br/>
<a href="#EditProfileStudent" class="editaccount_btn btn btn-default" >Update Profile</a>
</form>
<div id="profile_viewStudent" class="hide">
<h4>Profile</h4>
</div>
</div>
when I click on the link for view profile/edit profile it wont show or hide the other, I am left looking the same screen. Any help is appreciated, I've tried scanning other posts and to my knowledge none have been helpful yet.
Also, here's the CSS of the hide class.
div.hide {
display: none;}
form.hide {
display: none;}
You could try
document.getElementById('editstudentprofile').classList.add('unhide');
document.getElementById('editstudentprofile').classList.remove('hide');
Furthermore, in your example your using a , instead of a . after document in two lines.
I am using primeNG and i have made an inputgroup with it. This input field should be moved to the center and i know that i should use text-align: center on the envelopping container for this. However when i do this the inputgroup still won't move to the right, i really don't know what is causing this. This is my code:
css
.middle {
text-align: center;
}
html
<div class="middle ui-inputgroup">
<input type="text" size="5" pInputText placeholder="Value">
<span class="ui-inputgroup-addon"><code>cm</code></span>
</div>
The ui-inputgroup is a native class of primeNG, more info here: https://www.primefaces.org/primeng/#/inputgroup
Can anyone tell what is going on?
EDIT: Your code is causing the button below the input to float next to the input instead of centering the button. This is your code implemented plus the html code of the button:
<div class="ui-g-12 ui-md-4 test">
<div class="middle ui-inputgroup">
<input type="text" size="5" pInputText placeholder="Value">
<span class="ui-inputgroup-addon"><code>cm</code></span>
</div>
</div>
<button mat-raised-button id="newFilter" (click)="showDialog()">Add new filter</button>
</div>
it looks like this:
text-align of middle is already center,
<div class="ui-g-12 ui-md-4 test">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">
<i class="fa fa-user"></i>
</span>
<input pinputtext="" placeholder="Username"
type="text" class="ui-inputtext ui-corner-all ui-state-default ui-widget">
</div>
</div>
style:
.ui-g-12.ui-md-4.test {
margin: 0 auto;
}
input.ui-inputtext.ui-corner-all.ui-state-default.ui-widget {
text-align: center;
}
update:
<div class="ui-g-12 ui-md-6 test" style="margin: 0 auto;">
<div class="middle ui-inputgroup" style="display: inline-flex;">
<input type="text" size="5" pinputtext="" placeholder="Value">
<span class="ui-inputgroup-addon"><code>cm</code></span>
</div>
<button id="newFilter">Add new filter</button>
</div>
I am creating a login, and want to add a container to another container. One container is light blue and the other one is dark blue. This is a screen shot of what it currently looks like
I want to be able to have the dark blue container the full width of the other container, and the height to be bigger than what it currently is. This is the structure of the html below:
<div class="container">
<a href="../index.html">
<img id="logologin" src="../img/logo1.png" alt="logo"/>
</a>
<div class="card card-container">
<?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
<?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>
<p id="profile-name" class="profile-name-card"></p>
<form class="form-signin" method="POST">
<span id="reauth-email" class="reauth-email"></span>
<label> <input type="text" name="username" id="username" class="form-control" placeholder="Username"></label>
<label><input type="password" name="password" id="password" class="form-control" placeholder="Password" required></label>
<div id="remember" class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block btn-signin" type="submit" name="submit">Sign in</button>
<div class="link"> <a href="register4.php"> Forgot Password?
</a></div>
</form><!-- /form -->
<div class="forgot-password">
Don't have an account? <a href="register4.php"> Create an account
</a>
</div><!-- /forgot-password -->
</div><!-- /card-container -->
</div><!-- /container -->
This is the css I have for the dark blue container I am trying to build
.forgot-password {
color: #848585;
font-size:14px;
background-color: #5967b9;
}
Thanks for any help in advance - js fiddle containing all code https://jsfiddle.net/68t0t1jt/
You can bypass the card-container padding, that is the class with padding that is making impossible to inside elements to have the full width with this:
.card-container{
padding: 0 !important;
}
then you can add the padding or margin to the form element, to make it's contents back to the center:
<form class="form-signin" method="POST" style="padding: 40px 40px;">
and then you use this forgot-password class:
.forgot-password {
color: #848585;
font-size:14px;
background-color: #5967b9;
width: 100%;
//height: 75px --if you want to change height, just uncomment
}
very basic fiddle: https://jsfiddle.net/6L84ycr4/
Hope it helps you
Here is the updated fiddle : jsfiddle.net/68t0t1jt/1
As described in the comments, you just have to remove the padding from .card-container.card and reapply it to .form-signin
You Can Try:
<div class="container" style="height: inherit;" >
or height:100%
I am trying to make a search bar using html/bootstrap/Jquery which looks similar to the search bar found here:
https://us.letgo.com/en
So far I have that design but with only one text box:
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-offset-3 col-md-6">
<form class="" action="next_page.php" method="GET">
<div class="form-group" id="search_wrapper">
<input type="text" id="search_field" class="form-control" name="search_title" placeholder="Search By Name">
<button type="submit" id="search_button" class="btn btn-default">Search</button>
css
#search_field {
background-transparent;
height:40px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
border-color: #CCCCCC;
outline: none;
}
#search_button {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
position:absolute;
top:0;
right:0;
font-size: 17px;
width:120px;
height:40px;
}
#search_wrapper{
height:40px;
position:relative;
}
When I add another input between the button and input between the input and button, the input just displays below both the button and the text box.
<input type="text" id="search_field" class="form-control" name="search_place" placeholder="Search By Place">
EDIT 1
I made a jsfiddle
https://jsfiddle.net/7v6hc9sz/1/
If that doesnt just link you to it, please let me know in a comment that it doesn't work. I have never used jsfiddle before.
I would recommend leveraging the Bootstrap native styles to the maximum extent possible, as they give you a robust set of tools to build your site.
For this particular issue, you're looking for Bootstrap's Inline Form styles.
Here's an example from their docs:
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Name</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Email</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe#example.com">
</div>
<button type="submit" class="btn btn-default">Send invitation</button>
</form>
You also are looking for Bootstrap Input Groups which will allow you to "pair" the button to the right of the last input.
Note the following things about that code:
1. The form has a class of form-inline. This is important, as it tells Bootstrap to line things up inline.
2. Each pair of label / inputs gets wrapped in a div with the class form-group. This tells Bootstrap to display this "group" (label and input) inline.
3. Each input gets a class of form-control. This tells bootstrap to style it up as an input.
Now, applying those classes to your markup, to achieve what you want, would look something like this:
<!-- Add the class "form-inline" -->
<h3>
Important:<br>form-inline does not appear correctly unless you make the preview pane wide!
</h3>
<form class="form-inline" action="next_page.php" method="GET">
<div class="form-group">
<input type="text" id="search_field" class="form-control" name="search_title" placeholder="Search By Name">
<!-- close the "form-group" div and start a new div -->
</div>
<!-- here we use "input-group" to get the submit tight "against" the input -->
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button type="submit" id="search_button" class="btn btn-default">Search</button>
</span>
</div>
</form>
Here's a Working Fiddle
You just need to make an inline form - the bootstrap website has examples.
It looks like this:
<form class="form-inline">
<div class="form-group">
<label class="sr-only" for="inputOne">Input One</label>
<input type="text" class="form-control" id="inputOne" placeholder="Input Two">
</div>
<div class="form-group">
<label class="sr-only" for="inputTwo">Input Two</label>
<input type="text" class="form-control" id="inputTwo" placeholder="Input Two">
</div>
<button type="submit" class="btn btn-default">Search</button>
</form>
Working bootply
Here's a bootply with connected fields by Rachel S
I had to create a custom CSS class to override the default margins for this form:
margin-right: -10px;
As well as remove the rounded corners of the following input element:
border-top-left-radius: 0;
border-bottom-left-radius: 0
See working demo below (need to see in in full-page).
You'd need to add this to your nav bar, of course.
.my-search {
padding: 1px;
margin-right: -10px;
display: inline-block;
}
.my-search2 input#search2 {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>my attempt</h2>
<hr/>
<form class="form-inline">
<div class="form-group">
<div class="input-group my-search">
<input type="text" class="form-control" id="search1" placeholder="s1">
</div>
<div class="input-group my-search2">
<input type="text" class="form-control" id="search2" placeholder="s2">
<div class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</div>
</div>
</div>
</form>
I want to change the style of my bootstrap form to my own custom css. So, I create a class in my form, but the changes I make to the class's css isn't changing the style of the form.
Here's my form:
<li class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown"> <span class="glyphicon glyphicon-log-in"></span> Login</a>
<div class="dropdown-menu" style="padding: 5px; padding-bottom: 5px;">
<form class="login-form" action="[YOUR ACTION]" method="post" accept-charset="UTF-8">
<input id="user_username" placeholder="Email" style="margin-bottom: 15px;" type="text" name="user_username" size="30" />
<input id="user_password" placeholder="Password" style="margin-bottom: 15px;" type="password" name="user_password" size="30" />
<input id="user_remember_me" style="float: left; margin-right: 10px;" type="checkbox" name="user_remember_me" value="1" />
<label class="string optional" for="user_remember_me"> Remember me</label>
<input class="btn btn-primary" style="clear: left; width: 100%; height: 32px; font-size: 13px;" type="submit" name="commit" value="Sign In" />
</form>
</div>
</li>
And here's my css:
.login-form {
left:0px;
right:0px;
width:300px;
margin:0 auto;
background-color:#000000;
padding:60px;
}
If .login-form class is coming from an external style sheet you should determine that the style sheet is being loaded by the browsers. In Chrome go to the View menu and from the Developer submenu choose Developer Tools. For most these tools appear at the bottom of the browsers' view port. Click on the Sources tab and then click on your CSS file; if you see the CSS then the style is loading. If not, then the style is not loading and it may be a problem with the URL that points to the style sheet.
Additionally you should validate your style sheet in W3C validator as an error in an earlier or later style could be causing a cascading error. Common Cascading errors are failing to properly close a style rule with a curly brace or terminating a property's value(s) with a semi-colon.