Bootstrap grid system rows in row - html

I am trying make some grid in bootstrap and I do not know whether I'm coming correctly so here is my HTML:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row bg-white">
<div style="background-color: #0a4d85" class="col-md-6">
<div class="col-md-12" style="background-color: #00B312">
<p>text</p>
</div>
</div>
<div style="background-color: #0000BB" class="col-md-6">
<div class="row"> <!-- This row -->
<div class="col-md-12" style="background-color: #0c0c0c">
<p>text</p>
</div>
<div class="col-md-12" style="background-color: #00a1e8">
<p>text</p>
</div>
</div>
</div>
</div>
</div>
Result from this code is like this (no padding for right side):
But if I remove "row" class (selected in HTML comment) result is as i expected:
So how? I am doing something wrong or row in row is bad practise?

Bootstrap grid is based on a 12 column layout. There are three major components containers, rows, and columns. Rows are horizontal groups of columns that ensure your columns are lined up properly. Hence, Row in row is not good practice. Column classes indicate the number of columns you’d like to use out of the possible 12 per row. So if you want three equal-width columns, you’d use .col-md-4.

Related

CSS / Bootstrap: Want to locate 2 div side by side in a div

My question above below is my current code:
<!-- Masthead-->
<header class="masthead">
<div class="container">
<div class="masthead-subheading" style="color: black;">Welcome</div>
<div class="masthead-heading" style="color: black;">Dr. Lim Wee Chai</div>
<div class="ml12" style="color: black;">My Life, My Journey</div>
<div style="float:left;"><img src = "about.png" width="50%" height="32%"/></div>
</div>
</header>
and below is the result
Can anyone help to on how to make sure that the image is at the left side (beside word Dr. Lim Wee Chai)?
You should use rows and columns
https://getbootstrap.com/docs/4.0/layout/grid/
You are not using bootstrap grid utility. Read the Grid doc to learn more.
You can set a two-column grid that set div side-by-side using col class assign to the div. However, the grid has a defined structure that you will have to follow. See below.
Any column must have a row. In another word, the column/s should be the child/s of the row.
<div class="row">
<div class="col"></div>
...
</div>
You can set a min one and max twelve columns per row. Read bootstrap grid doc to learn more.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col">
<img class="img-fluid" src="https://cdn.pixabay.com/photo/2019/12/30/14/13/snail-4729777_960_720.jpg"/>
</div>
<div class="col">
<h2>Equal-width</h2>
<p>For example, here are two grid layouts that apply to every device and viewport, from xs to xl. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.</p>
</div>
</div>
</div>
You are looking for < nobr> !

Bootstrap grids responsive

I have a 3 column layout with the code here for example. Right now when the browser window gets smaller it stacks from the 1st column on top, 2nd in the middle and then 3rd is last as expected. I want the columns to behave this way when the columns get smaller.
First - This column gets hidden and I have already established that in the CSS
Third - This is the first column on top.
Second- This column is on bottom.
<div class="row">
<div class="col-sm-3">First</div>
<div class="col-sm-6">Second</div>
<div class="col-sm-3">Third</div>
</div>
Use .order- classes for controlling the visual order of your content.
<div class="container">
<div class="row">
<div class="col-sm-3">
First, but unordered
</div>
<div class="col-sm-6 order-12">
Second, but last
</div>
<div class="col-sm-3 order-1">
Third, but first
</div>
</div>
</div>

Multiple rows inside a row with Bootstrap 4

I'm trying to create a full width page using Bootstrap. I have a setup similar to this:
<body>
<div class="container-fluid">
<div class="row">
The first row goes here
</div>
<div class="row">
The second row goes here
</div>
<div class="row">
The third row goes here
</div>
</div>
</body>
If I wanted to create a row inside a row, how would I do that? This is what I am trying to achieve:
<body>
<div class="container-fluid">
<div class="row">
<div class="row text-center">
<h1>Some title</h1>
</div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-4">
Grid perhaps
</div>
<div class="col-md-4">
More grid
</div>
<div class="col-md-2"></div>
</div>
</div>
</div>
</body>
So basically I want to put the title on one row and some grids on another row. The tricky part here is, I want to place some columns that are 4 columns wide in the middle, and then have "2 columns padding" on the left and right.
My question may sound like others, but is unique because of the padding. How do I make this layout properly?
Bootstrap has a smart (but delicate) gutters system providing "natural" (margins + paddings) for content on all devices 1.
This system is based on two simple assumptions:
columns are immediate children of .rows 2
content is placed inside columns
That's why, if you want to place a .row inside another .row (to further divide one of your cols), you'd have to use this markup:
<div class="row">
<div class="col-12">
<div class="row">
<div class="col-md-4 offset-md-2">
Grid perhaps
</div>
<div class="col-md-4">
More grid
</div>
</div>
</div>
</div>
The above doesn't make much sense by itself (you could just use the markup of the child row and you'd get the same result). But it's useful when you want to offset (or limit) an entire area of a layout, like this:
<div class="row">
<div class="col-md-8 offset-md-2 col-sm-10 offset-sm-1 col offset-0">
<div class="row">
<div class="col-md-6">Grid</div>
<div class="col-md-6">More grid</div>
<div class="col-md-6">Grid</div>
<div class="col-md-6">More grid</div>
<div class="col-md-6">Grid</div>
<div class="col-md-6">More grid</div>
<div class="col-md-6">Grid</div>
<div class="col-md-6">More grid</div>
<div class="col-md-6">Grid</div>
<div class="col-md-6">More grid</div>
</div>
</div>
</div>
See this fiddle for a live example.
1 To get rid of Bootstrap's gutters (in v4), one would need to apply no-gutters class on .row.
2 This is a "general principle", not a "strict rule". Other elements are allowed (and even recommended) as direct children of .rows (such as column breaks). At the other end, other elements extend from .rows (such as .form-rows), thus inheriting the gutters system and being valid column parents.
.row should not be the immediate child of another .row
.col* should not be the immediate child of another .col*
From the Bootstrap docs:
"Content should be placed within columns, and only columns may be
immediate children of rows."
I don't understand why you think you need a row in a row, and what's wrong with just using your layout w/o the nested row. Do you realize that col-12 is the width of a full row?
<div class="container-fluid">
<div class="row">
<div class="col-12 text-center">
<h1>Some title</h1>
</div>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-4">
Grid perhaps
</div>
<div class="col-md-4">
More grid
</div>
<div class="col-md-2">
</div>
</div>
</div>
http://www.codeply.com/go/jfrWn4QDf1
Bootstrap 4, the same rule applies:
"Rows are wrappers for columns. Each column has horizontal padding
(called a gutter) for controlling the space between them... In a grid
layout, content must be placed within columns and only columns may be
immediate children of rows" __ Bootstrap 4.1 Docs
Linked: Columns must be immediate children of rows?

How to nest columns in Bootstrap?

In the Bootstrap documentation it's stated that to nest content with the grid system I must add a new .row and set of .col-sm-* columns within an existing .col-sm-* column. However, nesting just the .col-sm-* columns w/o adding a new .row seems to work as well.
I wonder what difference does the new .row make?
You can have columns nested in another column but they should generally be inside a row. The rows have negative margins to account for the padding on the columns, so if you have columns nested inside columns without a row in between, it will mess up the alignment of your page.
Rows are used to create horizontal groups of columns. Rows also help in keeping the elements in the same line. Doing this will make all the elements in a well-structured format.
Try this both and you we will understand by yourself.
USING ROW
<div class="container-fluid">
<h1>Hello World!</h1>
<p>Resize the browser window to see the effect.</p>
<div class="row">
<div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:lavenderblush;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div>
</div>
<div class="row">
<div class="col-sm-4" style="background-color:red;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:yellow;">.col-sm-4</div>
</div>
WITHOUT USING ROW
<div class="container-fluid">
<h1>Hello World!</h1>
<div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:lavenderblush;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:red;">.col-sm-4</div>
<div class="col-sm-4" style="background-color:yellow;">.col-sm-4</div>
</div>

How can I use a Grid inside a Block Grid Column in Foundation 6?

I would like to have a responsive list of items, dynamically fetched from the server (so the number of items is unknown).
According to Foundation 6, the block grid is the way to go. I have used the block grid successfully to show images, but when I try to create a grid inside a block grid column, it doesn't look too good.
Here is my code:
<div class="foods row small-up-1 medium-up-3 large-up-4">
<div class="food column">
<div class="row">
<div class="small-6 medium-4 large-3 columns picture ar-wrapper ar-4-3">
<div class="ar-container">
</div>
</div>
<div class="small-6 medium-8 large-9 columns data">
<div class="row">
<div class="small-12 columns title">
</div>
</div>
<div class="row">
<div class="small-12 columns description">
</div>
</div>
<div class="row">
<div class="small-12 columns restaurant-name">
</div>
</div>
</div>
</div>
</div>
</div>
None of the additional classes interfere with the width of change any float settings.
The result looks like this:
The tall block on the left is the "large-3 columns" element and the selected (blue-ish) element is the "large-9 columns" large div (it's made on a large screen). So by the looks of it, the block grid column has more than 12 simple grid columns.
I appreciate any help or alternative solutions on how to solve this.