Pull right button with input in header - html

I'm trying to pull on the right in the header a button with a input text field, this is my code:
<div class="page-header">
<div class="pull-left">
<h2>Header</h2>
</div>
<div class="pull-right">
<div class="form-group label-floating">
<label class="control-label" for="focusedInput1">Search</label>
<input class="form-control" id="focusedInput1" type="text">
</div>
<button id="show-hide-filter-button" class="btn btn-raised btn-default">Mostra Filtro</button>
</div>
<div class="clearfix"></div>
</div>
so as you can see, I have on the left the title of the header and on the right i want on the same line the input and one or more buttons, the problem is if I add only button it's work perfectly, all on the same line, if I add a form-group in input go in two line as you can see in the image below.
How can I have all in the same line?
Thanks

Try to make this div
div class="form-group label-floating"
go inline with the button
button id="show-hide-filter-button"
using css "display: inline-block" on the div (by default it goes with "display: block")

Add display:inline to the .form-group, or display:flex to the .pull-right

You can do this with Flexbox just use display: flex on both header and pull-right class.
.page-header, .pull-right {
display: flex;
align-items: center;
justify-content: space-between;
}
<div class="page-header">
<div class="pull-left">
<h2>Header</h2>
</div>
<div class="pull-right">
<div class="form-group label-floating">
<label class="control-label" for="focusedInput1">Search</label>
<input class="form-control" id="focusedInput1" type="text">
</div>
<button id="show-hide-filter-button" class="btn btn-raised btn-default">Mostra Filtro</button>
</div>
</div>

The buttons and the field container should have "display:inline-block;":
<div class="page-header">
<div class="pull-left" style="float:left;">
<h2>Header</h2>
</div>
<div class="pull-right" style="float:right;">
<div class="form-group label-floating" style="display:inline-block;">
<label class="control-label" for="focusedInput1">Search</label>
<input class="form-control" id="focusedInput1" type="text">
</div>
<button style="display:inline-block;" id="show-hide-filter-button" class="btn btn-raised btn-default">Mostra Filtro</button>
</div>
<div class="clearfix" style="clear:both;"></div>
</div>

Try this fiddle
<nav class="navbar page-header">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Header</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right">
<div class="form-group">
<input type="text" placeholder="search" class="form-control search">
</div>
<button type="submit" class="btn btn-transparent">Mostra Filtro</button>
</form>
</div>

Related

Centering button on website

<body>
<div class="navbar-collapse collapse inverse" id="navbar-header">
<div class="container-fluid">
<div class="about">
<h4>text</h4>
<p class="text</p>
<div class="imgWrapper">
<img id="photo" src="path/to/file"/>
</div>
</div>
<div class="social">
<p>text</p>
</div>
</div>
</div>
<div class="navbar navbar-static-top navbar-dark bg-inverse">
<div class="container-fluid">
<a id="logoutButton" href="logout.php" class="btn btn-lg btn-
primary">Logout</a>
<button id="navbar-button" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-header" aria-controls="navbar-header" aria-expanded="false" aria-label="Toggle navigation"></button>
Media Manager
</div>
</div>
<section class="jumbotron text-xs-center">
<div class="container">
<h1 class="jumbotron-heading">Album list</h1>
<p id="jumbotron-header-text" class="lead text-muted">text</p>
<p>
<div id="fakeButton" class="col-sm-4 col-xs-4">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
</p>
</div>
</section>
...
I'm trying to center the element with the id "fakeButton" on my Jumbotron, and I'm failing miserably. Things I've tried:
1) CSS Selector
#fakeButton {
margin: auto !important;
float: none !important;
}
2) Using bootstrap class text-center:
<div class="span7 text-center"></div>
I'm using Bootstrap 4. Most of the code is taken from this Bootstrap example:
http://v4-alpha.getbootstrap.com/examples/album/
I've made sure Bootstrap is installed correctly, but I can't seem to figure out how to center that element.
Use Bootstrap's text-center class with col-xs-12 on #fakeButton.
Use:
<div id="fakeButton" class="col-xs-12 text-center">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
Instead of:
<div id="fakeButton" class="col-sm-4 col-xs-4">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
Have a look at the snippet below:
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div class="navbar-collapse collapse inverse" id="navbar-header">
<div class="container-fluid">
<div class="about">
<h4>text</h4>
<p class="text"></p>
<div class="imgWrapper">
<img id="photo" src="path/to/file"/>
</div>
</div>
<div class="social">
<p>text</p>
</div>
</div>
</div>
<div class="navbar navbar-static-top navbar-dark bg-inverse">
<div class="container-fluid">
<a id="logoutButton" href="logout.php" class="btn btn-lg btn-
primary">Logout</a>
<button id="navbar-button" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-header" aria-controls="navbar-header" aria-expanded="false" aria-label="Toggle navigation"></button>
Media Manager
</div>
</div>
<section class="jumbotron text-xs-center">
<div class="container">
<h1 class="jumbotron-heading">Album list</h1>
<p id="jumbotron-header-text" class="lead text-muted">text</p>
<p>
<div id="fakeButton" class="col-xs-12 text-center">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
</p>
</div>
</section>
Hope this helps!
Your markup is incorrect, change the following:
This:
<p class="text</p>
To this:
<p class="text"></p>
And this:
<div id="fakeButton" class="col-sm-4 col-xs-4">
To this:
<div id="fakeButton" class="col-xs-12">
The class text-xs-center in your .jumbotron element is already centering the button.
The button has display: inline-block, that is why it is centered with text-align: center declared in its ancestor.
EDIT:
You actually have more things to correct:
Wrap your #fakeButton in a .row not in a <p> tag.
Change this:
<p>
<div id="fakeButton" class="col-xs-12">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
</p>
To this:
<div class="row">
<div id="fakeButton" class="col-xs-12">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
</div>
And then add this to your CSS:
input[type="file"] {
display: block;
}
input[type="file"] {
display: block;
}
<link href="https://v4-alpha.getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar-collapse collapse inverse" id="navbar-header">
<div class="container-fluid">
<div class="about">
<h4>text</h4>
<p class="text"></p>
<div class="imgWrapper">
<img id="photo" src="path/to/file" />
</div>
</div>
<div class="social">
<p>text</p>
</div>
</div>
</div>
<div class="navbar navbar-static-top navbar-dark bg-inverse">
<div class="container-fluid">
<a id="logoutButton" href="logout.php" class="btn btn-lg btn-
primary">Logout</a>
<button id="navbar-button" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-header" aria-controls="navbar-header" aria-expanded="false" aria-label="Toggle navigation"></button>
Media Manager
</div>
</div>
<section class="jumbotron text-xs-center">
<div class="container">
<h1 class="jumbotron-heading">Album list</h1>
<p id="jumbotron-header-text" class="lead text-muted">text</p>
<div class="row">
<div id="fakeButton" class="col-xs-12">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>
</div>
</div>
</section>
Try adding the text-center class to the button itself :
<label for="files" class="btn btn-primary btn-lg text-center">Select Image</label>
or change your html to this instead:
<div id="fakeButton" class="col-xs-12 text-center">
<label for="files" class="btn btn-primary btn-lg">Select Image</label>
<input id="files" style="visibility:hidden;" type="file">
</div>

Extend search input in navbar header

In this example the search input is very long until the end of page. I copied the html code but mine is short for some reason and couldnt really figure out the part that makes it long ? What's the trick ?
Code for my navbar:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("KTEMB Veritabanı", "Index", "Members", new { area = "" }, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Üyeler", "Index", "Members")</li>
<li>#Html.ActionLink("Kayıtlı Personel", "Index", "Employees")</li>
</ul>
#*#Html.Partial("_LoginPartial")*#
<form class="navbar-form">
<div class="form-group" style="display:inline;">
<div class="input-group">
<input type="text" class="form-control" placeholder="What are searching for?">
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span> </span>
</div>
</div>
</form>
</div>
</div>
</div>
The example you cited uses Bootstrap 3.1, using 3.3.x would explain why it doesn't work for you. Some of the other examples you'll come across use older versions of Bootstrap too - so they won't work with newer versions of BS.
This works a little better. Leaving the .form-group class at 100% width (which is default) is one of the things that causes a problem, so changing it to 95% or less works. Also, it appears to fail when using a float class, like .navbar-right, (which is why it was converted to inline) so watch out for those...
<div class="collapse navbar-collapse">
<form class="navbar-form" role="search">
<div class="form-group" style="display:inline; float:right; width:95%;">
<div class="input-group" style="width:100%">
<input type="text" class="form-control" placeholder="Search">
<span class="input-group-addon" style="width:1%"><span class="glyphicon glyphicon-search"></span></span>
</div>
</div>
</form>
</div>
You need to use .form-group and .input-group, like:
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" placeholder="What are searching for?">
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span> </span>
</div>
</div>

Bootstrap Center Form & Logo like Responsive Search Engine

What would be the best way to have a logo and form in the center of the page while being responsive?
Currently, I have something like
<div class="container">
<img src="logo.jpg" class="logo img-responsive center-block">
<form role="form">
<div class="form-group center-block">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search">
<span class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</form>
</div>
then I edited it slightly in the css;
.form-group { margin-top: 15px; width: 50% }
.logo { width: 300px; }
However, now the logo will not resize like the input box does.
now you'll need to change the col size for each media that you need xs sm md and lg but this would do the trick that you are looking for.
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<img src="http://placehold.it/250x300" class="logo img-responsive center-block" />
<form role="form">
<div class="form-group center-block">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" /> <span class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</form>
</div>
</div>
</div>
i assumed that you need a fluid container, the offset col would take , and for farther reading check this
Demo
A fluid container does the trick, but a fixed container should be able to keep it center without taking all the screen span which is annoying on medium+ resolutions.
Also, media queries should keep .container within a specific width for responsiveness' sake.
<div class="container">
<div class="row">
<div class="col-md-12">
<img src="http://placehold.it/250x300" class="logo img-responsive center-block" />
<form role="form">
<div class="form-group center-block">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" /> <span class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</div>
</form>
</div>
</div>
</div>

.container is not showing below .navbar

I am using bootstreap 3. My code is below div .navbar is showing properly on top.
But problem is with .container it is not showing below the .navbar
What change should I make to work it properly
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">My Office</a>
</div>
<div class="navbar-collapse collapse pull-right top-margin">
<form class="form-inline" method="post" action="login">
<div class="form-group">
<input type="text" placeholder="Username" name="userName" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" name="password" class="form-control">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs10">Join us</div>
<div class="col-xs-2">
<button type="submit" class="btn btn-default">Sign Up</button>
</div>
</div>
</div>
</body>
You need to add padding to the top of the body for fixed navbars:
body { padding-top: 70px; }
From the docs:
The fixed navbar will overlay your other content, unless you add
padding to the top of the <body>. Try out your own values or use our
snippet below. Tip: By default, the navbar is 50px high.

Bootstrap fixed navbar breaks with password field

i have this markup for twitter bootstrap
<!DOCTYPE html>
<html>
<head>
<title>Modus - Clientportal</title>
<link rel="stylesheet" href="/packages/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/main.min.css">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Modus - Clientportal</a>
<p class="navbar-text">You are logged in as Sebastian</p>
</div>
<div class="navbar-collapse collapse">d
<div class="navbar-right">
<ul class="nav navbar-nav ">
<li>Dashboard</li>
<li>Settings</li>
<li>Profile</li>
<li>Help</li>
</ul>
<a class="btn btn-default navbar-btn" href="/logout">Logout</a>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">profile.title</h3>
</div>
<div class="panel-body">
<form method="POST" action="/profile" accept-charset="UTF-8">
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputPasswordConfirmation1">Password Confirmation</label>
<input type="password" class="form-control" id="exampleInputPasswordConfirmation1" placeholder="Password">
</div>
<input class="btn btn-primary" type="submit" value="profile.btn.save">
</form>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/packages/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
if i load this up the fixed-navbar breaks and lose its height.
The only solution i found yet was to change the type of the Password fields to anything else, but that cant be the solution since i need a password field there.
any suggestions?