Form side-by-side breaking line in Bootstrap 3 - css

Trying to show a form side-by-side without success:
https://jsfiddle.net/eo6srkjr/
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Panel</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-10">
<form action="#" role="form" method="post">
<a class="btn btn-danger btn-xs">Option 1</a>
</form>
<form action="#" role="form" method="post">
<a class="btn btn-success btn-xs">Option 2</a>
</form>
</div>
</div>
</div>
</div>
Any thoughts on it? Thanks

If you are looking to make both button side by side I have done so here
https://jsfiddle.net/eo6srkjr/6/
Add this to CSS
#test{
float: left;
}
#test2{
float: left;
}
Add a div to each button you want to style. Like this
<div id="test">
<form action="#" role="form" method="post">
<a class="btn btn-danger btn-xs">Option 1</a>
</form>
</div>
<div id="test2">
<form action="#" role="form" method="post">
<a class="btn btn-success btn-xs">Option 2</a>
</form>
</div>
If this is not the effect desired, let me know and ill help you accordingly.
Then just style each div accordingly to make it positioned exactly as you want.

Related

Can't align buttons to panel-title

I have what I call a tricky problem. I want to align two buttons with the panel-title and have them justified right. However, when I put them in I get this:
https://jsfiddle.net/mwoods98/fo58qswn/3/
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>Order Summary Details</strong></h3><span class="pull-right" style="position: relative;top: -110%;"><button class="btn btn-primary pull-right" type="button"><span class="pull-right" style="position: relative;top: -110%;">Print Summary</span> <button class="btn btn-primary" type="button">Print Label</button></button></span>
</div>
</div>
</div>
</div>
</body>
</html>
The result I want is the buttons aligned on the same line as the title.
Thanks!
You can set the position of buttons absolute :
<span class="pull-right" style="position: absolute;top: 2px;right: 21px;">
<button type="button" class="btn btn-primary pull-right">Print Summary</button>
<button type="button" class="btn btn-primary">Print Label</button>
</span>
https://jsfiddle.net/xewLs6t2/
Another solution can be something like that:
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading" style="height: 40px;">
<h3 class="panel-title"><strong>Order Summary Details</strong></h3>
<div style="margin-top: -25px;" class="pull-right">
<button type="button" class="btn btn-primary">Print Summary</button>
Print Label
</div>
</div>
</div>
</div>
</div>

How could I resize input-group?

I'm creating a jumbotron and trying to put an input-group form to make searches on my website. The problem is when I add the form with input and button and try to resize the form to 100% it doesn't stick together and the input text doesn't resize.
How could I fix this problem ?
trying
<div class="jumbotron">
<div class="row">
<div class="col-md-4">
<div class="img-responsive" style="margin:-50px 0 -20px 20px;">
<img src="~/Imagens/logo.png" />
</div>
</div>
<div class="col-md-4">
#using (Html.BeginForm("view", "Home", FormMethod.Post, new { role = "form" })){
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<div class="input-group">
<input type="text" class="form-control" placeholder="What do you looking for ?">
<div class="input-group-btn">
<button class="btn glyphicon glyphicon-search"></button>
</div>
</div>
}
</div>
<div class="col-md-4">
#Html.Partial("_LoginPartial")
</div>
</div>
</div><!--jumbotron-->
You have some custom CSS on your page?
maybe this code can be the problem..
take a look:
<div class="jumbotron">
<div class="row">
<div class="col-md-4">
<form>
<div class="input-group">
<input type="text" class="form-control" placeholder="What do you looking for ?">
<div class="input-group-btn">
<button class="btn glyphicon glyphicon-search"></button>
</div>
</div>
</form>
</div>
</div>
https://jsfiddle.net/AlvaroAlves/0jrkhuy0/
Your Bootstrap code works fine, check this pen.
<div class="input-group">
<input type="text" class="form-control" placeholder="What do you looking for ?">
<div class="input-group-btn">
<button class="btn glyphicon glyphicon-search"></button>
</div>
</div>
Most probably some CSS code is interfering with Bootstrap's CSS.

Bootstrap search box and button aligned to right of header text (not in nav bar)

I'm using Bootstrap 3.3.7 and am having difficulty getting the search box and button to drop underneath the heading text when viewed on small screen.
I'd like to get it to stack as follows:
Large screen (as it is currently):
[Title] [search input] [submit button]
Smaller screen:
[Title]
[search input] [submit button]
Small screen:
[Title]
[search input]
[submit button]
Any help much appreciated. I've been at this for ages and my CSS skills are too lacking for me to make any decent headway. Thanks.
Large screen:
Smaller screen (button gets cut off):
Small screen:
Here's my code:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<!-- all the navigation stuff -->
</div>
</nav>
<!-- main content -->
<div class="container" role="main">
<div class="page-header">
<form action="" method="GET" class="form-inline pull-right">
<div class="form-group form-group-lg has-feedback">
<label class="sr-only" for="search">Search</label>
<input type="text" class="form-control" name="q" id="search" placeholder="Search">
<span class="glyphicons glyphicons-xl glyphicons-group form-control-feedback"></span>
</div>
<button type="submit" class="btn btn-lg btn-success">
<span class="glyphicons glyphicons-search" aria-hidden="true"></span>Search
</button>
</form>
<h2>Quite Long Header Text</h2>
</div>
<!--rest of page content -->
</div>
update
Thank you # Robert C. This is how things look with your suggestion:
and
and
The button has reduced in size which is great, but the input field now spans the entire width. I think it would all work just fine if the small button and input field were in the same row. This would mean that even on small devices I'd only need two stacks.
Could you suggest how I might go about reducing the size of the input box so that it will allow the button to stick to its left side on the same 'row'?
Thanks a lot
You will need to add some wrappers to make sure everything is lined up (or, alternatively remove the padding on your <h2>) but something along the following should provide you a Bootstrap Grid solution:
<div class="container" role="main">
<div class="row">
<div class="col-md-8 col-sm-8 col-xs-12">
<h2>Quite Long Header Text</h2>
</div>
<div class="col-md-4 col-sm-4 col-xs-12">
<form action="" method="GET" class="form-main">
<div class="col-md-10 col-sm-10 col-xs-12">
<label class="sr-only" for="search">Search</label>
<div class="input-group">
<input type="text" class="form-control input-search" name="q" id="search" placeholder="Search">
<span class="input-group-addon group-icon"><span class="glyphicon glyphicon-user"></span>
</div>
</div>
<div class="col-md-2 col-sm-2 col-xs-12">
<button type="submit" class="btn btn-success">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span><span class="hidden-sm hidden-xs"> Search </span>
</button>
</div>
</div>
</div>
</div>
You can see a Bootply fiddle here: http://www.bootply.com/bhvdBwcX4b
To view the Bootply fiddle on smaller screens be sure to click the mobile icon, as simply resizing your browser will result in a rendering error warning.
Of the top of my head you need to use col and rows to work it out. Here is the col part...
<!-- main content -->
<div class="col-lg-6 col-md-6 col-sml-12">
<h2>Quite Long Header Text</h2>
</div>
<div class="col-lg-6 col-md-6 col-sml-12">
<form action="" method="GET" class="form-inline">
<div class="form-group form-group-lg has-feedback">
<label class="sr-only" for="search">Search</label>
<input type="text" class="form-control" name="q" id="search" placeholder="Search">
<span class="glyphicons glyphicons-xl glyphicons-group form-control-feedback"></span>
</div>
<button type="submit" class="btn btn-lg btn-success">
<span class="glyphicons glyphicons-search" aria-hidden="true"></span>Search
</button>
</form>
</div>
I have restructured my previous solution for your problem. Have a look at the example here CODEPEN.
Hope it will be helpful to you
HTML:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<!-- all the navigation stuff -->
</div>
</nav>
<!-- main content -->
<div class="section-main">
<div class="container" role="main">
<div class="row">
<div class="col-xs-12 col-md-6">
<h2>Quite Long Header Text</h2>
</div>
<div class="col-xs-12 col-md-6">
<form action="" method="GET" class="form-main form-inline nofloat-xs pull-right pull-left-sm">
<div class="form-group form-input-fields form-group-lg has-feedback">
<label class="sr-only" for="search">Search</label>
<div class="input-group">
<input type="text" class="form-control input-search" name="q" id="search" placeholder="Search">
<span class="input-group-addon group-icon"> <span class="glyphicon glyphicon-user"></span>
</span>
</div>
<button type="submit" class="btn btn-lg btn-success btn-submit">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span> Search
</button>
</div>
</form>
</div>
</div>
<!--rest of page content -->
</div>
</div>
CSS:
.form-main {
margin-top: 15px;
}
.form-input-fields {
margin-bottom: 0;
}
.section-main {
margin-top:40px;
background-color: lightgrey;
padding: 20px 0;
}
.group-icon {
background-color:#fff;
border:0;
}
.input-search {
border:1px solid #fff;
box-shadow:none;
}
#media (max-width: 992px) {
.pull-left-sm {
float: left !important;
}
}
#media (max-width: 767px) {
.nofloat-xs {
float: none !important;
}
.btn-submit {
margin-top:10px;
}
}
enjoy :)

Vertical-alignment text in Bootstrap's List Group

I've tried to vertical align text in Bootstrap's list group (inside of tag li) with display: table-cell; line-height: 50px; vertical-align: middle;, but it doesn't work at all. Help me with it, please. ;)
<div class="row">
<div class="col-md-12">
<ul class="list-group">
<li class="list-group-item clearfix">Byl jsi pořádně prošťouchán uživatelem <strong>hakys</strong>.
<form action="my_pokes.php" method="post">
<span class="pull-right">
<button class="btn btn-success" name="poke_hakys">Šťouchnout zpět</button>
<button class="btn btn-danger" name="delete_hakys">Smazat šťouchnutí</button>
</span>
</form>
</li> </ul>
</div>
</div>
You can do something like this, and then you won't need to override the list-group-item style..
<div class="row">
<div class="col-md-12`">
<ul class="list-group">
<li class="list-group-item text-right">
<span class="pull-left">
Byl jsi pořádně prošťouchán uživatelem <strong>hakys</strong>.</span>
<form action="my_pokes.php" method="post" class="form-inline">
<span>
<button class="btn btn-success" name="poke_hakys">Šťouchnout zpět</button>
<button class="btn btn-danger" name="delete_hakys">Smazat šťouchnutí</button>
</span>
</form>
</li>
</ul>
</div>
</div>
Demo: http://codeply.com/go/6H4wBABPGw
I made some changes to your code. The biggest change is that instead of setting up one 12 span column I divided it into three. this makes it easier for laying out items in bootstrap.
Let me know if this helps you.
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-5">
<ul class="list-group">
<li class="list-group-item clearfix">Byl jsi pořádně prošťouchán uživatelem <strong>hakys</strong>.</div>
<div class="col-md-4">
<form action="my_pokes.php" method="post"> <span class="pull-right">
<button class="btn btn-success" name="poke_hakys">Šťouchnout zpět</button>
<button class="btn btn-danger" name="delete_hakys">Smazat šťouchnutí</button>
</span>
</form>
</li>
</ul>
</div>
</div>
</div>

Embed a search form in Bootstrap 3 panel heading

I'm attempting to embed a search form at the right side of a panel heading:
<div class="panel-heading">
<h3 class="panel-title">Results <span class="badge">6</span></h3>
<form class="form-inline pull-right" role="search" method="get" action="/tbl">
<div class="form-group">
<input type="text" name="criteria" class="form-control" value="<%= params[:criteria] if params[:criteria] %>" placeholder="<%= params[:criteria]? params[:criteria] : 'Enter search criteria (e.g. FOOBAR_%)' %>">
<div class="input-group-btn">
<button class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
Unfortunately, I'm having alignment issues:
In Safari (8.0.3):
In Firefox (35.0.1):
Is there a way to do this, preferably without custom CSS?
JSFiddle
Almost, see this fiddle
I put the heading and search box into col divs, but id have to add a little padding to he title to get it to line up with the search box
CSS:
.padFix{
padding-top:8px;
}
HTML:
<div class="panel-heading ">
<div class="row">
<div class="col-sm-6">
<h3 class="panel-title padFix">Results <span class="badge">6</span></h3></div>
<div class="col-sm-6">
<form role="search" method="get" action="/tbl">
<div class="input-group">
<input type="text" name="criteria" class="form-control" value="<%= params[:criteria] if params[:criteria] %>" placeholder="<%= params[:criteria]? params[:criteria] : 'Enter search criteria (e.g. FOOBAR_%)' %>">
<div class="input-group-btn">
<button class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
Here am sharing my answer, this might be useful
JS Fiddle
Here is the code
HTML
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left" style="padding-top: 7.5px;">
Header
</h4>
<div class="btn-group pull-right">
<input type="text" class="custom_input">
<button class="btn btn-success pull-right" style="height: 30px;">
Search
</button>
</div>
</div>
<div class="panel-body">
Content Body
</div>
<div class="panel-footer">
Content Footer
</div>
</div>
</div>
</div>
CSS
.custom_input {
padding: 4px 5px;
border: 1px solid #d3e0e9;
border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
border-right: none;
height: 30px;
}
thank You :-)

Resources