Bootstrap navbar change height - html

I don't know why, my navbar isn't centered. My buttons aren't aligned at the center and I want to change the navbar height.
How I could do that? This is the navbar:
And this is the code:
.extra-margin {
margin-bottom: 1%;
}
.extra-padding{
padding-top: 1%;
}
.extra-button{
margin-left: 5%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<header>
<nav class="navbar navbar-dark bg-dark navbar-fixed-top extra-margin">
<ul>
<a class="btn btn-outline-primary" href="{% url 'interface:users' %}">Lista Pacientes</a>
<a class=" btn btn-outline-success" href="{% url 'interface:users' %}">AƱadir Paciente</a>
<a class=" btn btn-outline-danger" href="{% url 'interface:users' %}">Eliminar Paciente</a>
</ul>
<form class="navbar-form navbar navbar-right extra-padding" action="{% url 'interface:users' %}" method="post">
{% csrf_token %}
<div class="input-group">
<input type="text" name="search_text" class="form-control" placeholder="ID del Paciente">
<div class="input-group-btn">
<button class="btn btn-outline-warning extra-button" type="submit"> Buscar Paciente
</button>
</div>
</div>
</form>
</nav>
</header>

To put the buttons inline use the following style change:
nav ul
{
margin: 0;
}
In default, the ul has some bottom margin.
https://www.bootply.com/ruS4ad9IoW

You have to change this in your CSS using the #navbar-height.
When you create the navbar have a minimum of 50px.
Now about vertical centered you can use vertical-align: middle; and change the margin to 0 in the ul element, normally ul have a margin

Related

How do I add elements below my navbar using bootstrap?

I have attempted to place elements below the navigation bar I created, however, it keeps distorting the NavBar. I have used bootstrap so I was hoping I could add a form underneath the code below, it's honestly just an issue of spacing and I have read the bootstrap documentation yet I still find it difficult. The code below is fine but could someone try to add a form or some kind of input box below it, please. Thank you, guys.
<! this is where the nav bar starts to be made>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark navbar-fixed-top">
<!this is the length and theme of the navigation bar is set>
<ul class="navbar-nav pl-2">
<! i've added padding left as i need to space out items in the nav bar well>
<li class="nav-item">
District 1
</li>
<! the home button is the name of the store>
<div class="mx-auto">
<form class="mx-auto order-0 col px-md-5">
<! this is the creation of the search bar>
<div class="mx-auto input-group mt-1">
<div class="input-group-prepend" style="margin-left: 380px; margin-top: 5px;">
<button class="btn btn-outline-secondary" type="button" id="button-addon1"><img
src="https://img.icons8.com/pastel-glyph/2x/search--v2.png" alt="Search" class="mx-auto"
width="20" height="20"></button>
<! this is the image for the search button function>
</div>
<input type="text" class="form-control" placeholder="" aria-label="Example text with button addon"
aria-describedby="button-addon1" style="margin-top: 5px;">
</form>
</div>
</ul>
<ul class="navbar-nav ml-auto ">
<li class="nav-item" style="padding-right: 120px;">
<a id="one" href="SignIn.php" class="nav-link" style="font-size: 15px;">Hello, <br> Sign in!</a>
</li>
<! this is the sign in button>
<li class="nav-item mr-5">
<a id="two" href="SignIn.php" class="nav-link"><img
src="https://img.icons8.com/pastel-glyph/2x/shopping-cart--v2.png" alt="Cart" width="40"
height="40"></a>
</li>
<! this is the shopping cart button>
</li>
</ul>
Here are examples of input fields and forms below your nav, is this what you are looking for?
Please see comments in the code to understand better.
Comment if you have more questions.
.flex-c-row {
display:flex;
align-items:center;
margin:25px;
} /* setting the display to flex, which is by default 'row' with items side-by-side; give it align-items:center to align items vertically in the available space */
.flex-c-row > * {
margin:50px; /* space all direct child elements of the outer container by 50px on all sides top bottom right left */
}
.flex-c-col, form {
display:flex;flex-direction:column; /* same as above but set the flexbox direction of elements as a COLUMN so vertical */
}
input {
cursor:pointer;
}
form > * {
margin:25px 0;
}
<nav class="navbar navbar-expand-lg navbar-dark bg-dark navbar-fixed-top">
<ul class="navbar-nav pl-2">
<li class="nav-item">
District 1
</li>
<div class="mx-auto">
<form class="mx-auto order-0 col px-md-5">
<div class="mx-auto input-group mt-1">
<div class="input-group-prepend" style="margin-left: 380px; margin-top: 5px;">
<button class="btn btn-outline-secondary" type="button" id="button-addon1"><img
src="https://img.icons8.com/pastel-glyph/2x/search--v2.png" alt="Search" class="mx-auto"
width="20" height="20"></button>
</div>
<input type="text" class="form-control" placeholder="" aria-label="Example text with button addon"
aria-describedby="button-addon1" style="margin-top: 5px;">
</div>
</form>
</ul>
<ul class="navbar-nav ml-auto ">
<li class="nav-item" style="padding-right: 120px;">
<a id="one" href="SignIn.php" class="nav-link" style="font-size: 15px;">Hello, <br> Sign in!</a>
</li>
<li class="nav-item mr-5">
<a id="two" href="SignIn.php" class="nav-link"><img
src="https://img.icons8.com/pastel-glyph/2x/shopping-cart--v2.png" alt="Cart" width="40"
height="40"></a>
</li>
</ul>
</nav>
<!-- so here we simply add the container div for our 3 input examples -->
<div class="flex-c-row">
<div class="flex-c-col">
<span>This is an input field</span>
<input type="datetime-local">
</div>
<div class="">
<form>
<h3>This is a basic form.</h3>
<input>
<input>
<textarea cols="15" rows="25"></textarea>
</div>
<div class="flex-c-col">
<span>This is a color input field.</span>
<input type="color">
</div>
<div>
Codepen to play with:
https://codepen.io/larrytherabbit/pen/pobjKLw

Scrollbar too long due to bootstrap 4 navbar

This is a pretty funky issue.
I'm trying to create an frameless app using electron and bootstrap 4 and wanted to style the app a bit.
After a lot of work, I came by the most odd of issues I have encountered in the entire project.
This is not an electron issue tho (hence the lack of the relevant tag).
You see, I have a header element that is 87px height (to contain the navbar and window controls like maximize and close), with a main element under it that contains the actual content of the page.
<header>
<div class="window-control bg-primary">
<button class="btn btn-primary btn-sm float-right" (click)="exitApp()"><fa-icon [icon]="faTimes"></fa-icon></button>
<button class="btn btn-primary btn-sm float-right" *ngIf="isMaximized" (click)="unmaximizeWindow()"><fa-icon [icon]="faMinusSquare" ></fa-icon></button>
<button class="btn btn-primary btn-sm float-right" *ngIf="!isMaximized" (click)="maximizeWindow()"><fa-icon [icon]="faPlusSquare" ></fa-icon></button>
<button class="btn btn-primary btn-sm float-right" (click)="minimizeWindow()"><fa-icon [icon]="faMinus"></fa-icon></button>
</div>
<nav class="navbar navbar-expand navbar-dark bg-secondary">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<span class="text-primary font-weight-bold">9</span>AnimeDl
</a>
<ul class="nav navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="#">Discover</a></li>
</ul>
<form class="form-inline my-2 my-lg-0 mr-2">
<div class="input-group">
<input class="form-control bg-secondary border-0 text-center" aria-describedby="basic-addon1" type="search" placeholder="Search" aria-label="Search" #search (keyup)="searchChange(search.value)">
<div class="input-group-append">
<button class="btn btn-outline-primary bg-secondary text-white" type="button">
<fa-icon [icon]="faSearch"></fa-icon>
</button>
</div>
</div>
</form>
<button class="btn btn-primary" (click)="doDonate()">Donate</button>
</div>
</nav>
</header>
<app-donate-modal *ngIf="nagDonation"></app-donate-modal>
<app-waf-captcha *ngIf="_9anime.isWafActive" [siteKey]="_9anime.siteKey"></app-waf-captcha>
<main [hidden]="!isBusy" class="container-fluid bg-gray-dark">
<div class="content">
<app-loading-spinner></app-loading-spinner>
</div>
</main>
<main [hidden]="isBusy" class="container-fluid bg-gray-dark">
<router-outlet></router-outlet>
</main>
Now I added the following css to my stylesheet:
body {
overflow: hidden;
height: 100%;
}
main {
height: 100%;
padding-top: 25px;
position: absolute;
overflow-y: scroll;
}
.window-control {
height: 31px;
-webkit-app-region: drag;
-webkit-user-select: none;
button {
-webkit-app-region: none;
}
}
::-webkit-scrollbar {
width: 12px; /* for vertical scrollbars */
height: 12px; /* for horizontal scrollbars */
}
::-webkit-scrollbar-track {
background: map-get($theme-colors, "gray-dark");
}
::-webkit-scrollbar-thumb{
background: map-get($theme-colors, "primary");
}
::-webkit-resizer {
display: none;
}
This causes the "regular" scrollbar to be gone from the body and slams it into the main element
Now, here is the funky part.
When I remove the header (display: none) and scroll all the way down this is what I get:
The scrollbar reaches the bottom and says put, the cards show fully with a small padding at the bottom.
Now when I add the header back in again and scroll all the way down, this happens:
The cards don't fully show, there is no padding under it (like in the first screenshot) and the scrollbar scrolls farther than it should scroll.
My question is if anyone knows what is causing this issue and, more importantly, how to solve it.
solved it by adding an 87px thick border on the bottom of the content:
main {
border-bottom: 87px solid #ccc;
}

Change position of navbar-brand

I' d like to move my navbar-brand, just a bit to the right. The default position overlaps, a little, with another button. How can I do it?
Here is a bit of my html code:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button type="button" id="sidebarCollapse" class="navbar-btn">
<span></span>
<span></span>
<span></sp<an>
</button>
<a class="navbar-brand" href="#" >Agora</a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<form class="form-inline mx-auto my-2">
<input class="form-control mr-sm-1" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
Do i have to use CSS?
Code is well accepted :)
i understood that you want to get the button a little bet right from his current position
you can see this example here
so you can use bootstrap positioning classes with the navbar-brand as usual like
ml-*, mr-*
Add this in you CSS file.
.navbar-brand
{
position: absolute;
width: 100%;
left: 0;
text-align: right;
margin: auto;
}
You can check the running demo here. Position is center in demo, adjust the position to right or whatever you like.

Horizontal and Vertical alignment of a toolbar with Bootstrap elements

I am trying to create a page header / tool bar. This in an existing theme and there is a DIV at the top where this will reside. The basic premise is on the left a H2 title then on the right a bunch of bootstrap elements (search form, bottons, dropdowns etc.
I have tried all kinds of block, inline-block vertical-align etc. I can get the H2 to pull left and the toolbar to pull right but the toolbar elements all pull up to the top of the container div. I just want a clean looking layout with all the elements aligned along their horizontal axis.
I think the pull-right may be part of the problem. That seems to pull the right div up to the top.
Here is a Bootply link: http://www.bootply.com/BPucyP8mpk
<div class"container">
<div id="left">
<h2 class="">Title</h2>
</div>
<div id="right">
<form class="form form-horizontal">
<input type="text" placeholder="search field" class="form-control">
<button type="submit" class="btn">search</button>
</form>
<button class="btn btn-default">Button</button>
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
<div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Choice1
</li>
<li>Choice2
</li>
<li>Choice3
</li>
<li class="divider"></li>
<li>Choice..
</li>
</ul>
</div>
</div>
</div>
UPDATE:
Here is the computed CSS that wraps the header I am trying to format:
border-bottom-width: 1px;
border-top-color: rgb(103, 106, 108);
border-top-style: none;
border-top-width: 0px;
box-sizing: border-box;
color: rgb(103, 106, 108);
display: block;
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
height: 70px;
line-height: 18px;
margin-left: -15px;
margin-right: -15px;
padding-bottom: 12px;
padding-left: 20px;
padding-right: 20px;
padding-top: 0px;
width: 1318px;
This is from my custom theme I have installed. This is the computed CSS from this wrapper div:
<div class="row wrapper border-bottom white-bg page-heading">
</div>
UPD:
The most suitable method for this task is use Flexbox
Check it out: http://www.bootply.com/CtVmUbzrlr
<div class="row">
<div id="left" class="col-sm-3 col-md-5">
<h2 class="">Title</h2>
</div>
<div id="right" class="col-sm-9 col-md-7">
<form class="form form-horizontal">
<div class="input-group">
<input type="text" placeholder="search field" class="form-control">
<span type="submit" class="input-group-addon">search</span>
</div>
</form>
<button class="btn btn-default">Button</button>
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
<div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Choice1
</li>
<li>Choice2
</li>
<li>Choice3
</li>
<li class="divider"></li>
<li>Choice..
</li>
</ul>
</div>
</div>
</div>
.row{
border: 1px solid #000;
}
#right{
display: flex;
align-items: center;
height: 66px;
justify-content: flex-end;
}
.input-group{
width: 200px;
}
Check this out:
<div class="col-lg-4">
<h2 class="">Title</h2>
</div>
<div class="col-lg-8">
<div class="row">
<form class="form form-horizontal">
<div class="col-lg-8">
<input type="text" placeholder="search field" class="form-control">
</div>
<div class="col-lg-4">
<button type="submit" class="btn btn-block">search</button>
</div>
</form>
</div>
<div class="row">
<div class="col-lg-12">
<button class="btn btn-default">Button</button>
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
<div class="btn-group"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Choice1
</li>
<li>Choice2
</li>
<li>Choice3
</li>
<li class="divider"></li>
<li>Choice..
</li>
</ul>
</div>
</div>
</div>
</div>
you can check bootply also : http://www.bootply.com/LmGjZM6fHH
You need to manage your layout with the col-md-*
This is just for the demo, you can arrange with you own way
What about utilizing the navbar component from bootstrap?
http://getbootstrap.com/components/#navbar
I think the example here pretty much sums up your needs.
Basically I've added classes navbar-btn to the buttons, and navbar-form to the form to get them to align properly. I added the class navbar-right to both the form and the group of buttons.
http://www.bootply.com/IySnkX2ioK
Edit: The navbar-default class was just added to outline the bounds of the navbar, not part of the solution.
First thing is that if you want to have your search box on left - place it first and then button group with dropdown. Second, don't place navbar-rigth inside another navbar-rigth. And the last thing - just wrap your right-side elements in one div and add to it a little padding
Updated link

How to make a <button> in Bootstrap look like a normal link in nav-tabs?

I'm working in (formerly Twitter) Bootstrap 2 and I wanted to style buttons as though they were normal links. Not just any normal links, though; these are going in a <ul class="nav nav-tabs nav-stacked"> container. The markup will end up like this:
<form action="..." method="post">
<div class="row-fluid">
<!-- Navigation for the form -->
<div class="span3">
<ul class="nav nav-tabs nav-stacked">
<li><button type="submit" name="op" value="Link 1">Link 1</button></li>
<li><button type="submit" name="op" value="Link 2">Link 2</button></li>
<!-- ... -->
</ul>
</div>
<!-- The actual form -->
<div class="span9">
<!-- ... -->
</div>
</div>
</form>
Does Bootstrap have any way to make these <button>s look like they were actually <a>s?
As noted in the official documentation, simply apply the class(es) btn btn-link:
<!-- Deemphasize a button by making it look like a link while maintaining button behavior -->
<button type="button" class="btn btn-link">Link</button>
For example, with the code you have provided:
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<form action="..." method="post">
<div class="row-fluid">
<!-- Navigation for the form -->
<div class="span3">
<ul class="nav nav-tabs nav-stacked">
<li>
<button class="btn btn-link" role="link" type="submit" name="op" value="Link 1">Link 1</button>
</li>
<li>
<button class="btn btn-link" role="link" type="submit" name="op" value="Link 2">Link 2</button>
</li>
<!-- ... -->
</ul>
</div>
<!-- The actual form -->
<div class="span9">
<!-- ... -->
</div>
</div>
</form>
Just make regular link look like button :)
Click here!
"role" inside a href code makes it look like button, ofc you can add more variables such as class.
Just add remove_button_css as class to your button tag. You can verify the code for Link 1
.remove_button_css {
outline: none;
padding: 5px;
border: 0px;
box-sizing: none;
background-color: transparent;
}
Extra Styles Edit
Add color: #337ab7; and :hover and :focus to match OOTB (bootstrap3)
.remove_button_css:focus,
.remove_button_css:hover {
color: #23527c;
text-decoration: underline;
}
In bootstrap 3, this works well for me:
.btn-link.btn-anchor {
outline: none !important;
padding: 0;
border: 0;
vertical-align: baseline;
}
Used like:
<button type="button" class="btn-link btn-anchor">My Button</button>
Demo
Just get rid of the background color, borders and add hover effects. Here's a fiddle: http://jsfiddle.net/yPU29/
<form action="..." method="post">
<div class="row-fluid">
<!-- Navigation for the form -->
<div class="span3">
<ul class="nav nav-tabs nav-stacked">
<li><button type="submit" name="op" value="Link 1" class="button-link">Link 1</button></li>
<li><button type="submit" name="op" value="Link 2" class="button-link">Link 2</button></li>
<!-- ... -->
</ul>
</div>
<!-- The actual form -->
<div class="span9">
<!-- ... -->
</div>
</div>
</form>
CSS:
.button-link {
background-color: transparent;
border: none;
}
.button-link:hover {
color: blue;
text-decoration: underline;
}
I've tried all examples, posted here, but they do not work without extra CSS. Try this:
<button type="button" class="btn btn-success">Google</button>
Works perfectly without any extra CSS.
here is a example:
<form method="POST" >
<button type="submit" class=" linkish my-1 far fa-thumbs-down fa-2x"> </button>
<button type="submit" class=" linkish btn btn-primary">click me</button>
</form>
and css style :
.linkish {
background-color: transparent!important;
border: 0!important;
color: blue!important;
cursor: pointer!important;
display: inline!important;
margin: 0!important;
outline: none!important;
padding: 0!important;
text-decoration: none!important;
}
.linkish:hover {
text-decoration: underline!important;
}
this is just example , and change it based on your case / requirements.
i hope this helpful .