Materialize Grid for irregular boxes not workings - html

I am trying to make the front end using materialize and I have used Django for the backend. The current look I am getting is something like this:
And I want it to be more like this:
I am using Django and Materialize. And here is the code I have written.

This layout is easy to achieve with CSS grid, but if you wanted to approximate it with the Materialize grid, you just need to fix your columns and use a bit of flex.
The example you want to replicate has two main columns:
<div class="row">
<!-- Two columns, wider on the left -->
<div class="col s12 l8">Left</div>
<div class="col s12 l4">Right</div>
</div>
The left hand column than has nested rows and columns, like this:
<div class="row">
<!-- Three columns -->
<div class="col s4"></div>
<div class="col s4"></div>
<div class="col s4"></div>
</div>
<div class="row">
<!-- One column -->
<div class="col s12"></div>
</div>
<div class="row">
<!-- Three columns -->
<div class="col s4"></div>
<div class="col s4"></div>
<div class="col s4"></div>
</div>
We need to use flex on two of the rows - this forces the content to stretch to fit. Be careful with flex, it breaks the grid system at small screen sizes.
We also need a bit of css to force the button to fill the container, and to remove the margin bottom from the last row. I've created a wrapper called .content that we'll use to apply the padding (same as the margin from the rows for consistency).
Codepen.

Related

Bootstrap - How to span a column using container/row/col classes

I am trying to create the equivalent using Bootstrap and I understand the use of container and the use of DIVs with class="row" and class="col". I just dont know how I would do a colspan like in HTML when you use TABLE s.
With example below "Sum: $180" how do I do that using a Container with DIV cols and rows
Here is an example for you:
<div class="container border">
<div class="row border">
<div class="col border">Column</div>
<div class="col border">Column</div>
</div>
<div class="row border">
<div class="col-12">Column</div>
</div>
</div>
As ths says in the comments, the col-12 is the key.
I used the help document from https://getbootstrap.com/docs/5.2/layout/grid/ to build the code above. I added the borders for visibility.
Depending on your usage you might need to watch out for the responsiveness of the grid on smaller screens as the columns will wrap underneath each other.
Hope this helps.

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>

Different layout for columns grid at md and at sm/xs - Bootstrap

guys. I have a little problem here working with bootstrap. I am trying to make a div container with a row containing 3 columns equally proportioned in width :
<div class="row">
<div class="col-md-4" style="background:red;">logo</div>
<div class="col-md-4" style="background:blue;">content</div>
<div class="col-md-4" style="background:yellow;">content+imgs</div>
</div>
</div>
The problem I have is that I want the column with 'logo' to be the second one (after 'content') on xs/sm devices or at resizing the browser window. I tried with push and pull, but I want the columns to be one above each other, not inline, as at the md devices. I have no clue how to do that, any help? :)
Using order classes with bootstrap, you can change the order of the columns responsively.
This example will put the second column first on XS and SM screens.
<!--bootstrap 4-->
<div class="row">
<div class="col-md-4 order-2 order-md-1">first</div>
<div class="col-md-4 order-1 order-md-2">second</div>
<div class="col-md-4 order-3 order-md-3">third</div>
</div>
edit:
For bootstrap 3 (3.3.7) you will need to use push & pull classes. In your case, you would have to make the logo the second column. Mobile counts as the starting point in bootstrap development.
<!-- bootstrap 3 -->
<div class="row">
<div class="col-md-4 col-md-push-4" style="background-color:red;">content</div>
<div class="col-md-4 col-md-pull-4" style="background-color:blue;">logo</div>
<div class="col-md-4" style="background-color:yellow;">content+imgs</div>
</div>

Apply offset to column on the right - Ionic grid

I am building an hybrid-app with ionic and I am trying to build a grid with two columns with width: 25%. This is the snippet with my code:
<div class="row">
<div class="col col-offset-25 col-25">1</div>
<div class="col col-25">2</div>
<div class="col col-25"> <!-- Empty --> </div>
</div>
The structure is working, but I have to use an empty column to get the result. Is it possible to apply col-offset-25 on the right of the second <div> tag?
If you remove the third column you should get what you are looking for (if I understand you intention right)
<div class="row">
<div class="col col-offset-25 col-25">1</div>
<div class="col col-25">2</div>
</div>
The first column will have offset 25%, take 25% if the width. The second column will be the next and will also 25% of the width. And after that there will be 25% gap

Bootstrap grid positioning

so I'm trying to make a bootstrap website but I don't really know how to customize the widths and position of these grids. I'm a bootstrap beginner. Could you please help me? It DOESN'T have to be accurate so bad but I need to keep the layout.
How it should look like:
http://i.imgur.com/WAE161o.png
HTML:
<div style="margin-top:200px;" class="container">
<div class="row clearfix">
<div class="col-md-4 column">
</div>
<!--THIS ONE IS FOR THE MIDDLE, CENTERED AD-->
<div class="col-md-4 column">
</div>
<div class="col-md-4 column">
</div>
</div>
<div class="row clearfix">
<div class="col-md-2 column">
</div>
<!--THIS ONE IS FOR BUTTONS STICKED TO THE POST ON THE LEFT-->
<div class="col-md-1 column">
</div>
<!--THIS ONE IS FOR THE POST AND BUTTONS STICKED ON THE BOTTOM-->
<div class="col-md-4 column">
</div>
<!--THIS ONE IS FOR THE SIDEBAR-->
<div class="col-md-3 column">
</div>
<div class="col-md-2 column">
</div>
</div>
</div>
From Bootstrap 3.0 release
col-vp-push-x = push the column to the right by x number of columns, starting from where the column would normally render -> position: relative, on a vp or larger view-port.
col-vp-pull-x = pull the column to the left by x number of columns, starting from where the column would normally render -> position: relative, on a vp or larger view-port.
vp = xs, sm, md, or lg
x = 1 thru 12
So the answer to your question is push/pull columns. For example, your ad row should be like this:
<div class="row">
<div class="col-sm-8 col-sm-pull-2 col-sm-push-2 advertisement">
your center column
</div>
</div>
and so on. See fiddle here
If you need specific columns with pixel-specific widths, you can't use the Bootstrap grid. The Bootstrap grid is broken into 12 equal sized columns. You can still use Bootstrap, just not the grid part. There is some limited customization that can be done with the grid system, but I don't think it can approach what you are trying to do. You'll need to use custom CSS to position the site how you want it.
If you just want something similar and don't care about exact widths, then you should follow the grid documentation. You are moving in the right direction but when you have nested columns you need to make sure you wrap in a row, which you don't have. You can also use the col-md-offset-* styles to shift columns so you don't have to "use" all 12 columns. For example for the main part of the site you might want the first column to be ".col-md-3 .col-md-offset-4" and the second ".col-md-3".