Bootstrap: hide the line between the rows - html

I try to divide a page in 2 rows with bootstrap and when I do that, there comes up a line in between. Can I remove/hide it somehow?
<div class="container-fluid">
<div class="row">
<div class="col-md-12 panel">
<div class="col-md-2">
<button class="btn btn-primary" type="submit" style="margin-top: 10px">Button1</button>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10 panel">
<div class="col-md-4">
<input type="text" class="form-control" placeholder="..." />
</div>
<div class="col-md-2">
<button class="btn btn-primary" type="submit">Button2</button>
</div>
</div>
</div>
</div>

The .panel adds a box-shadow. Either don't use it or remove it with..
.panel {
box-shadow: initial;
}
http://www.codeply.com/go/fNXo7yZu2T

You should place your 2 main .col-md divs inside one common .row, not two different rows.
see bootstrap guide
And then play with your .col-md divs.
I suggest the following:
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<button class="btn btn-primary" type="submit" style="margin-top: 10px">Button1</button>
</div>
<div class="col-md-6 panel">
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control" placeholder="..." />
</div>
<div class="col-md-6">
<button class="btn btn-primary" type="submit">Button2</button>
</div>
</div>
</div>
</div>

Columns need to be wrapped in rows and that is ALL the columns at the same level - you have created 2 rows with just single columns inside.
IE you have created 2 panels - panels need to differentiate between each other - therefore the line! (If you want to use panels properly check out http://getbootstrap.com/components/#panels and/or http://www.w3schools.com/bootstrap/bootstrap_panels.asp.)
You should be living at getboostrap.com until u get happy with BS!
Basic BS layout is
row
col col col
row
col
row - a row of columns inside another row (this sorts out the padding etc).
col
col
row
col
col
etc.
All wrapped in a container (containers should NOT be nested but they can be stacked one after the other).
Hope that makes sense (think it is clearer than HTML)
Columns always (well almost always - there are a couple of weird exceptions) need to be wrapped in rows otherwise padding, margins etc. go all over the place (took me ages to work out this simple rule).
It takes a while to get BS into your system.
One tip if you are using an IDE: Set up an insert (live template in PHPStorm) to do -
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
</div>
<!-- end row -->
</div>
<!-- end col next to row -->
I do this 100 times a day now! Saves sooooo much time.

Related

How make some boostrap columns taller than other?

So basically I'm still a begginer when it comes to doing interfaces on the web and trying to allign everything properly. I've decided to use the bootstrap library. I'm trying to make a modal dialog divided into multiple section but i'm really struggling to make some section stack on top of each other and have another section take up the entire space.
What I currently have :
https://i.gyazo.com/adeeb3cca0abb6dea4a5d002d3568afa.png
What I'm trying to achieve :
https://i.gyazo.com/e8513c243424cb71926ac838e8b1166e.png
This is the code I currently have with some sample text to try to delimiter each section :
<div class='container-fluid'>
<div class="row">
<div class="col-md-3" style='border:1px solid black;max-height:5vh;'>
STATUS
</div>
<div class="col-md-9" style='border:1px solid black;min-height:50vh;'>
L
</div>
<div class="col-md-3">
SOME TEXT ASDASDASDJLASDJKLASDJAD
ASDASDLASKD
aASDASDK:ASDKASDK
ASDASJDASDASDKASJDASDJ
</div>
<div class="col-md-9">
L
</div>
</div>
</div>
To match the image you've provided, you want two columns - one three wide with four rows, and one nine wide with one row.
The height of the rows in the left column will be determined by their contents. I've written an example with extra content in one row in the left column:
<div class="container">
<div class="row">
<div class="col-sm-3">
<div class="row">
3
</div>
<div class="row">
3<br>
wide<br>
but<br>
taller
</div>
<div class="row">
3
</div>
<div class="row">
3
</div>
</div>
<div class="col-sm-9">
9
</div>
</div>
</div>
JSFiddle for a live example.
You keep two main columns (3/9) and inside the first column you can add more container. You can also add styles or classes to them.
<div class="container-fluid">
<div class="row" >
<div class="col-md-3" style='border:1px solid black;min-height:50vh;'>
<div style="min-height:10vh">10vh</div>
<div style="min-height:20vh">10vh</div>
<div style="min-height:10vh">10vh</div>
<div style="min-height:10vh">10vh</div>
</div>
<div class="col-md-9" style='border:1px solid black;min-height:50vh;'>L</div>
</div>
</div>

How could I change the appearance of the HTML view?

Consider the below Angular 2 Template code :
<div *ngIf="artist">
<header class="artist-header">
<div *ngIf="artist.images.length > 0">
<img class="artist-thumb img-circle" src="{{artist.images[0].url}}">
</div>
<h1>{{artist.name}}</h1>
<p *ngIf="artist.genres.length > 0">
Genres : <span *ngFor="let genre of artist.genres">{{genre}}</span>
</p>
</header>
<div class="artist-albums">
<div class="row">
<div class="col-md-3" *ngFor="let album of albums">
<div class="card bg-faded card-body album">
<div *ngIf="album.images.length > 0">
<img class="album-thumb img-thumbnail" src="{{album.images[0].url}}">
<h4>{{album.name}}</h4>
<a class="btn btn-default btn-block" routerLink="/album/{{album.id}}">Album Details</a>
</div>
</div>
</div>
</div>
</div>
</div>
In spite of applying class="col-md-3", all divs are appearing in a new line vertically. Below is the image shown. I want that 3 div should appear horizontally in one line. What's need to be changed within the above code?
If the whole code you posted is looped to display all these images, each of the col-md-3 is in a seperate row div, which creates a linebreak each time. So try to make the loop inside that row div, only for the col-md-3 elements.
Add the other bootstrap options to the div:
col-lg-3 col-md-3 col-sm-3 col-xs-3
Be sure that you do not have any margins or haven't override the default width from bootstrap using "!important" flag.
Try to see the live CSS using "inspect element" option in your browser and try to change the data there so you can figure out what is going on.

Overlay column 1 on column 2

I'm trying to implement a mobile view where the first column of the row goes on top of the second column.
Here's the code:
<div class="container-fluid">
<div class="row">
<div class="col-md-4"><div class="loginpart"><img id ="icon" src="../images/athletics-logo.png"/><h2>Athletes Profiling </h2>
<input type="button" class="login" name="login" value="Log In"/></div></div>
<div class="col-md-8" style="padding: 0"><img id ="header"/><div class="mantra"><h2>Go Wolves!</h2></div></div>
</div>
</div>
Now the thing is, I want the loginpart class to go on top of the col-md-8 when on mobile. I tried searching for answers but ended with nothing. I don't want it to stack on top of each other.
A | B = A goes on top of B
If the implementation or my understanding is faulty, please do educate me. Thanks!
Edit: I tried the push-pull bootstrap function, but all it does is put the second column under the first column (which isn't what I was hoping for), but instead overlap both columns when switched to mobile view, not stacked on top of each other.
Try position absolute with push. You can use Z-index to get the correct column on top.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-md-4" style="position: absolute; z-index: 1;">
<div class="loginpart">
<img id ="icon" src="" />
<h2 style="color: grey;">Athletes Profiling </h2>
<input type="button" class="login" name="login" value="Log In"/>
</div>
</div>
<div class="col-md-8 col-md-push-4">
<img id="header" src="" />
<div class="mantra">
<h2 style="color: blue;">Go Wolves!</h2>
</div>
</div>
</div>
</div>

Bootstrap CSS Styling Issue

I am having an issue with a dynamic form I am creating on my page.
I have a Row that contains 1 or more Divs that are 4 col in length. I would expect that after ever 3, it moves the next one down as it hits the 12 col limit.
Looking at the picture below, after we hit the first three fields I would think it would move the others down to their own row.
Here id the HMLT that my data is in. As you can see, each one is its own col within the row.
Is there something I am doing incorrectly with the way I have this formatted? Just not sure what else to try.
I believe it is proper to create a .row for every row on the page:
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
I had the same problem yesterday, what I found is that the container should have the col length specified in order to fix the problem.
Also I found useful to add additional divs in order to fix better the length of the fields.
My example:
<div class="form-group col-md-12">
<div class="row">
<div class="form-group col-md-3">
your label data
</div>
<div class="form-group col-md-4">
your input data
</div>
</div>
<div class="row">
<div class="form-group col-md-2">
your label data
</div>
<div class="form-group col-md-3">
your input data
</div>
</div>
</div>
I hope it helps.
It's hard to tell from your screenshot, but it looks like you have the whole thing (rows, columns, and some form groups) inside of a span element. Try using a div instead.
The problem: http://jsfiddle.net/24doudo0/
This seems to be an issue with how bootstrap handles grid wrapping. It doesn't handle as nicely as we would like. I can think of two solutions to this problem. The first is to insert rows after every third column when you loop over them in the backend. For that you can use the modulus operator. I don't know what backend language you are using, but I'll illustrate this approach using PHP because I'm lazy.
Lets assume you have an array of input names that you want to loop over and create columns for each.
<div class="row">
<? foreach ($inputs as $count => $name) : ?>
<div class="col-md-4">
<input type="text" name="<?=$name?>">
</div>
<? if (($count + 1) % 3 == 0) : // $count is 0 based. We need an index that starts at 1 so that we don't trigger a new row on the first loop (0 / 3 = 0 which is a remainder of 0) ?>
</div>
<div class="row">
<? endif; ?>
<? endforeach; ?>
</div>
The other solutions is a CSS based one. Pretty simple but is CSS3 only, so it won't work in IE 8 or less. This approach just clears the float after every third column. Demo here: http://jsfiddle.net/j0dtng4t/
[class*="col-"] {
background: #C55;
border: 1px solid white;
color: white;
}
[class*="col-"]:nth-of-type(3n + 1) {
clear:left;
}
Actually there are at least other 2 alternative solutions you can consider without adding row divs.
The first is adding heights to all the .col* elements , in this way they'll get ordered progressively and stack when they don't fit next to each other.(checkout the pen).
The second is using display flex on the div containing the .col* elements; it's not a bootstrap feature but it seems to suite your situation quite well.
In the pens I made I modified the col-* selectors but I suggest you use a new selector so not to mess with Bootstrap's grid style.
There seems to be some confusion on how floats work especially in a bootstrap grid.
Here is a simple bit of code that demonstrates how floats work
.container-fluid {min-width:638px;}
.container-fluid p{margin:0;font-size:1.2rem}
[class*="col-"] {
background: #C55;
border: 1px solid white;
color: white;
}
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-xs-4">
column 1 <p>we work because we are the same height</p>
</div>
<div class="col-xs-4">
column 2 <p>we work because we are the same height</p>
</div>
<div class="col-xs-4">
column 3 <p>we work because we are the same height</p>
</div>
<div class="col-xs-4">
column 1
</div>
<div class="col-xs-4">
column 2 <p>I'm tall, but my buddies aren't</p>
</div>
<div class="col-xs-4">
column 3
</div>
<div class="col-xs-4">
column 3
</div>
<div class="col-xs-4">
column 1
</div>
<div class="col-xs-6">
column 2 <p>I'm tall but because Fred is too wide he goes to the far left to fit</p>
</div>
<div class="col-xs-2">
column 3
</div>
<div class="col-xs-4">
Fred column 1
</div>
</div>
<div class="row">
<div class="col-xs-4">
inputs are taller than select
</div>
<div class="col-xs-4">
inputs are taller than select
</div>
<div class="col-xs-4">
selects are smaller
</div>
<div class="col-xs-4">
<input type="text" placeholder="i'm too tall" />
</div>
<div class="col-xs-4">
<input type="text" placeholder="i'm too tall" />
</div>
<div class="col-xs-4">
<select><option>i'm shorter</option></select>
</div>
<div class="col-xs-4">that's why i'm column 3</div>
</div>
</div>

Bootstrap: add margin/padding space between columns

I'm trying to put some extra margin/padding space between columns on my Bootstrap grid layout. I've tried this but I don't like the result. Here is my code:
<div class="row">
<div class="text-center col-md-6">
Widget 1
</div>
<div class="text-center col-md-6">
Widget 2
</div>
</div>
I want to add margin: 10px and padding:10px. Some people suggest to change their classes to col-md-5 with pull-left and pull-right, but the gap between them will be too large.
Simply add a div within col-md-6 that has the extra padding that you need. The col-md-6 is the 'backbone' to keep the column integrity, but you can add additional padding within it.
<div class="row">
<div class="text-center col-md-6">
<div class="classWithPad">Widget 1</div>
</div>
<div class="text-center col-md-6">
<div class="classWithPad">Widget 2</div>
</div>
</div>
CSS
.classWithPad { margin:10px; padding:10px; }
Bootstrap 5 (Update 2021)
Bootstrap 5 has still includes spacing utilities for padding. However, because of new RTL support "left" and "right" have been changed to "start" and "end". For example pl-2 is now ps-2.
pl-* => ps-* (padding-left)
pr-* => pe-* (padding-right)
ml-* => ms-* (margin-left)
mr-* => me-* (margin-right)
Additionally, Bootstrap 5 introduces new grid gutter classes that can be used to adjust the spacing between columns. The guttter is set on the row instead of each col-* inside the row. For example, use g-0 for no spacing between columns.
Bootstrap 5 column spacing demo
Bootstrap 4 (Update 2018)
Bootstrap 4 has spacing utilities that make adding (or substracting) the space (gutter) between columns easier. Extra CSS isn't necessary.
<div class="row">
<div class="text-center col-md-6">
<div class="mr-2">Widget 1</div>
</div>
<div class="text-center col-md-6">
<div class="ml-2">Widget 2</div>
</div>
</div>
You can adjust margins on the column contents using the margin utils such as ml-0 (margin-left:0), mr-0 (margin-right:0), mx-1 (.25rem left & right margins), etc...
Or, you can adjust padding on the columns (col-*) using the padding utils such as pl-0 (padding-left:0), pr-0 (padding-right:0), px-2 (.50rem left & right padding), etc...
Bootstrap 4 Column Spacing Demo
Notes
Changing the left/right margin(s) on col-* will break the grid.
Change the left/right margin(s) on the content of col-* works.
Change the left/right padding on the col-* also works.
I was facing the same issue; and the following worked well for me. Hope this helps someone landing here:
<div class="row">
<div class="col-md-6">
<div class="col-md-12">
Set room heater temperature
</div>
</div>
<div class="col-md-6">
<div class="col-md-12">
Set room heater temperature
</div>
</div>
</div>
This will automatically render some space between the 2 divs.
Just add 'justify-content-around' class. that would automatically add gap between 2 divs.
Documentation:
https://getbootstrap.com/docs/4.1/layout/grid/#horizontal-alignment
Sample:
<div class="row justify-content-around">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
You may use the padding and margin shorthand Bootstrap 4 classes as follows:
For extra small devices i.e. xs
{property}{sides}-{size}
For other devices/viewports (small, medium, large and extra large)
{property}{sides}-{breakpoint}-{size}
Where:
property = m for margin and p for padding
Following are sides shorthand meanings:
l = defines the left-margin or left-padding
r = defines the right-margin or right-padding
t = defines the top-margin or top-padding
b = defines the bottom-margin or right-padding
x = For setting left and right padding and margins by the single call
y = For setting top and bottom margins
blank = margin and padding for all sides
The breakpoint = sm, md, lg, and xl.
Combining all the above, the left padding complete code can be (for example):
For left padding in extra small devices
pl-2
or for medium to extra large
pl-md-2
Try This:
<div class="row">
<div class="text-center col-md-6">
<div class="col-md-12">
Widget 1
</div>
</div>
<div class="text-center col-md-6">
<div class="col-md-12">
Widget 2
</div>
</div>
</div>
I would keep an extra column in the middle for larger displays and reset to default when the columns collapse on smaller displays. Something like this:
<div class="row">
<div class="text-center col-md-5 col-sm-6">
Widget 1
</div>
<div class="col-md-2">
<!-- Gap between columns -->
</div>
<div class="text-center col-md-5 col-sm-6">
Widget 2
</div>
</div>
Super easy with flexbox. Leave room for some space by changing the columns to col-md-5
<div class="row widgets">
<div class="text-center col-md-5">
Widget 1
</div>
<div class="text-center col-md-5">
Widget 2
</div>
</div>
CSS
.widgets {
display: flex;
justify-content: space-around;
}
For those looking to control the space between a dynamic number of columns, try:
<div class="row no-gutters">
<div class="col">
<div class="inner">
<!-- content here -->
</div>
</div>
<div class="col">
<div class="inner">
<!-- content here -->
</div>
</div>
<!-- etc. -->
</div>
CSS:
.col:not(:last-child) .inner {
margin: 2px; // Or whatever you want your spacing to be
}
A solution for someone like me when cells got background color
HTML
<div class="row">
<div class="col-6 cssBox">
a<br />ba<br />ba<br />b
</div>
<div class="col-6 cssBox">
a<br />b
</div>
</div>
CSS
.cssBox {
background-color: red;
margin: 0 10px;
flex-basis: calc(50% - 20px);
}
In the otherside if you like to remove double padding between columns just add class "nogap" inside row
<div class="row nogap">
<div class="text-center col-md-6">Widget 1</div>
<div class="text-center col-md-6">Widget 2</div>
</div>
and create additional css class for it
.nogap > .col{ padding-left:7.5px; padding-right: 7.5px}
.nogap > .col:first-child{ padding-left: 15px; }
.nogap > .col:last-child{ padding-right: 15px; }
Thats it, check here: https://codepen.io/michal-lukasik/pen/xXvoYJ
I had the same issue and worked it out by nesting a div inside bootstrap col and adding padding to it. Something like:
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="custom-box">Your content with padding</div>
</div>
<div class="col-md-4">
<div class="custom-box">Your content with padding</div>
</div>
<div class="col-md-4">
<div class="custom-box">Your content with padding</div>
</div>
</div>
</div>
I have just found a solution that works for me, although it doesnt actually create a space between the boxes so may not be exactly what you are looking for.
border border-white
Doesn't actually create a space but gives the effect of space between cols. Only works if you have a bg-color obviously.
Try this:
<div class="row">
<div class="col-md-5">
Set room heater temperature
</div>
<div class="col-md-2"></div>
<div class="col-md-5">
Set room heater temperature
</div>
</div>
For the more curious, I have also found that adding
border: 5px solid white
or any other variant of your liking, to make it blend in, works superbly.