How to centralize Bootstrap grids - html

In my website I have a bar on the top of the page. It contains some music player elements. They will be kept in 3 columns. I would like to keep the bar all back in the top of the page, but the grids stay in the middle.
<div class="container navbar-inverse navbar-fixed-top" style="height:50px;">
<div class="row">
<div class="col-md-2">
<div class="playerButton pre"></div>
<div class="playerButton play" onClick="play()"></div>
<div class="playerButton next"></div>
</div>
<div class="col-md-8">
<div class="waveBar">
<div class="waveBarTheme"></div>
<div class="waveBarPlayed"></div>
</div>
</div>
<div class="col-md-2">
<div class="playerButton unmute"></div>
<div class="playerButton repeat"></div>
<div class="playerButton addToPlaylist"></div>
<div class="playerButton screen"></div>
<div class="playerButton share"></div>
</div>
</div>
</div>
DEMO: http://jsfiddle.net/danials/b88mc56g/
Any idea to have the bar full-width and grids in the center ?

You have to separate the container(which is what restricts the width) from the navbar. Like this:
<div class="navbar-inverse navbar-fixed-top" style="height:50px;">
<div class="container">
<div class="row">
<div class="col-md-2">
<p>Left box</p>
</div>
<div class="col-md-8">
<p>Center box</p>
</div>
<div class="col-md-2">
<p>Right box</p>
</div>
</div>
</div>
</div>
Updated JSFiddle

Related

bootstrap the right side divs are the half of the left side div

how to do something like that with bootstrap?
img cuz I do not know how to describe it
You can use Bootstrap grid to achieve this
<div class="row">
<div class="col-6">div-1</div>
<div class="col-6">
<div class="row">
<div class="col-12">div-2</div>
<div class="col-12">div-3</div>
</div>
</div>
</div>
You can try something like this:
<div class="container">
<div class="row">
<div class="col">
div 1
</div>
<div class="col">
<div class="row">
<div class="col">
div 2
</div>
</div>
<div class="row">
<div class="col">
div 3
</div>
</div>
</div>
</div>
</div>

Is there any way to make the image clickable, to get redirected to other asp.net page?

How can I make the image clickable so I can be redirected to other asp net page?
<div class="banner-section spad">
<div class="container-fluid">
<div class="row">
<div class="col-lg-5">
<div class="single-banner">
<img src="img/banner-1.jpg">
<div class="inner-text">
<h4>Homem</h4>
</div>
</div>
</div>
</div>
</div>
just wrap image into anchor tag
<div class="banner-section spad">
<div class="container-fluid">
<div class="row">
<div class="col-lg-5">
<div class="single-banner">
<img src="img/banner-1.jpg">
<div class="inner-text">
<h4>Homem</h4>
</div>
</div>
</div>
</div>
</div>
<div class="banner-section spad">
<div class="container-fluid">
<div class="row">
<div class="col-lg-5">
<div class="single-banner">
<img src="img/banner-1.jpg">
<div class="inner-text">
<h4>Homem</h4>
</div>
</div>
</div>
</div>

How to create a non-fixed sidebar (Bootstrap grid)

I can only find solutions for fixed sidebars (e.g. Creating a fixed sidebar alongside a centered Bootstrap 3 grid), but not for non-fixed ones, i.e. a sidebar that scrolls down with the content.
I am using a bootstrap grid (Bootstrap 4):
<nav class="navbar sticky-top">...</nav>
<!--content-->
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
<div class="col-md-3">
<img src=https://via.placeholder.com/150x130">
</div>
<div class="row">
...
</div>
</div>
I need a sidebar to the left of this content, but under my top navigation bar. How do I do this?
(the number of rows I need is undefined. They will later be generated by a php loop, so I don't think I can put the sidebar in the grid system)
Just put the content in a wrapper, put another DIV before that, wrap a row around them and apply the usual classes to divide the page width:
<nav class="navbar sticky-top">...</nav>
<!--content-->
<div class="container-fluid">
<div class="row">
<div class="col-md-2 sidebar">
SIDEBAR
</div>
<div class="col-md-10">
<div class="row">
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
<div class="col-md-3">
<img src="https://via.placeholder.com/150x130">
</div>
</div>
<div class="row">
some other content...
</div>
</div>
</div>
</div>
https://codepen.io/anon/pen/XZedxM

Align divs from different columns - Twitter bootstrap

I am using twitter bootstrap and trying to align two divs that belong to different columns.
The code so far:
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h2>header1</h2>
<div class="row">
<div class="col-md-2">
1
</div>
<div class="col-md-4">
2
</div>
</div>
<div class="row">
<div class="col-md-2">
1
</div>
<div class="col-md-4">
2
</div>
</div>
<div class="row">
<div class="col-md-2">
1
</div>
<div class="col-md-4">
2
</div>
</div>
<div class="row">
<div class="col-md-2">
1
</div>
<div class="col-md-4">
2
</div>
</div>
<div class="row">
<div class="col-md-2">
1
</div>
<div class="col-md-4">
2
</div>
</div>
<h2>header2</h2>
<div class="row">
<div class="col-md-2">
3
</div>
<div class="col-md-4">
4
</div>
</div>
</div>
<div class="col-md-6">
<h2>header3</h2>
<div class="row">
<div class="col-md-2">
3
</div>
<div class="col-md-4">
4
</div>
</div>
<h2>header4</h2>
<div class="row">
<div class="col-md-2">
3
</div>
<div class="col-md-4">
4
</div>
</div>
</div>
</div>
</div>
The above code produces the layout below:
Is there any way to align vertically header4 with header2 (and thus leave space between the end of the div of header3 and the start of the div of header4?
Edit: when I resize my window and make it smaller I want to keep (header1 and header2) AND (header3 and header4) together (ie header2 below header1). This is the current case in the provided html code.
Thank you
There is - you need to alter your HTML so instead of simply having a two column layout, you have a grid based two row two column layout, e.g (simplified)
<div class='row'>
<div class='col-md-6'>
<h1>Header 1</h1>
</div>
<div class='col-md-6'>
<h1>Header 3</h1>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<h1>Header 2</h1>
</div>
<div class='col-md-6'>
<h1>Header 4</h1>
</div>
</div>

Complex bootstrap spanning grid

Got a headache with complex spanning grid using bootstrap.
There are portrait and landscape blocs into 5 columns but they all have the same surface except the bloc number 1 that only got the same width.
It become complex when two portrait blocs shares the same row. Moving content with margin, is not suitable.
here you go: this is the fiddle Demo
<div class="row-fluid">
<div class="span4">
<div class="well">1<br/><br/><br/><br/><br/></div>
<div class="well">5</div>
</div>
<div class="span8">
<div class="span12"><div class="well">2</div></div>
<div class="row-fluid">
<div class="span8">
<div class="well">3</div>
<div class="well">6</div>
</div>
<div class="span4"><div class="well">4<br/><br/><br/><br/><br/></div></div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span2">
<div class="well">7<br/><br/><br/><br/><br/></div>
<div class="well">14<br/><br/><br/><br/><br/></div>
</div>
<div class="span10">
<div class="row-fluid">
<div class="span6">
<div class="well">8</div>
</div>
<div class="span6">
<div class="well">9</div>
</div>
</div>
<div class="row-fluid">
<div class="span3">
<div class="well">
10<br/><br/><br/><br/><br/>
</div>
</div>
<div class="span6">
<div class="well">11</div>
<div class="well">12</div>
</div>
<div class="span3">
<div class="well">
13<br/><br/><br/><br/><br/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div class="well">15</div>
</div>
<div class="span6">
<div class="well">16</div>
</div>
</div>
</div>
</div>
you are not completely free on the panel sizes using span, if you want a more precise result you should use custom percentages on the div width.