How to fill the grid row if some div is missing? - html

I'm using tailwindcss and this html:
REPL: https://play.tailwindcss.com/L8McFjGBVC
<div class="grid grid-cols-12">
<div class="col-span-4 bg-red-300">1</div>
<div class="col-span-4 bg-green-300" v-if="showSecondDiv">2</div>
<div class="col-span-4 bg-blue-300">3</div>
</div>
The second div can sometimes be missing.
I would like the third div to fill the row (together with the first one), as if it had class "col-span-8".
How can I fix?

You can add [&:nth-child(3n-1)]:last:col-span-8 to the 3rd div, so when it's the second and the last div, it will spam 8 columns.
<script src="https://cdn.tailwindcss.com"></script>
<div class="grid grid-cols-12">
<div class="col-span-4 bg-red-300">1</div>
<div class="col-span-4 bg-green-300">2</div>
<div class="col-span-4 [&:nth-child(3n-1)]:last:col-span-8 bg-blue-300">3</div>
</div>
<br>
<div class="grid grid-cols-12">
<div class="col-span-4 bg-red-300">1</div>
<div class="col-span-4 [&:nth-child(3n-1)]:last:col-span-8 bg-blue-300">3</div>
</div>

Related

Last block of grid not working in grid-row. Want to move the block till the next row from row 4 to 5

SIMPLE CALCULATOR DESIGN WITG GRID (ALL CODE PASTED)
Trying hard but the last equal(=) is not working
<div class="calculator">
<div class="display-area"></div>
<div class="button-section">
<div class="rows">
<div class="first-row">
<div id="cancel">C</div>
<div id="divide">/</div>
<div id="multiply">*</div>
<div id="delete">Del</div>
</div>
<div class="second-row">
<div id="seven">7</div>
<div id="eight">8</div>
<div id="nine">9</div>
<div id="minus">-</div>
</div>
<div class="third-row">
<div id="four">4</div>
<div id="five">5</div>
<div id="six">6</div>
<div id="plus">+</div>
</div>
<div class="fourth-row">
<div id="one">1</div>
<div id="two">2</div>
<div id="three">3</div>
<div id="equal">=</div>
</div>
<div class="fifth-row">
<div id="percent">%</div>
<div id="zero">0</div>
<div id="dot">.</div>
</div>
</div>
</div>
</div>
</div>
This is the pic for css where the code not working properly. The last equal block is not working in grid-rows as i want it to move down till the last row
enter image description here
This is the result i got after many tries
enter image description here

Bootstrap - Giving Small Spacing Between Columns

I am trying to adapt a layout on Bootstrap that I got from the designer. Two columns in the content has a small spacing, that I couldn't achieve with direct column-spacing (as it gives too much gap). Thus, I tried wrapping everything into a row and adding sub-columns inside my main columns. Here in the code, it's more clear:
<div class="container">
<div class="col-md-12 banner"></div>
<div class="row">
<div class="col-md-8">
<div class="col-md-12 leftSide">
</div>
<div class="col-md-12 leftSide">
</div>
</div>
<div class="col-md-4 rightSide">
<div class="col-md-12">
</div>
</div>
</div>
</div>
Now the spacing seems good but as I wrapped it in a row (I think), the right panel overflowed more then the banner.
It can be seen more clear on the fiddle: http://www.bootply.com/gMBrLvaK5C
The problem is the 'rightSide' panel.
How can I keep that spacing between 'leftSide' and 'rightSide', and fix the overflowing of the right column (because the spacing gets too much if I try achieving spacing with columns)? Or what is the best way to achieve that?
this is my personal solution, instead of add a class on the columns, create a div inside of a column, then you can place a div.banner and div.block like my example:
http://www.bootply.com/PEIiDnp9VD
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="banner"></div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="block"></div>
</div>
<div class="col-md-4">
<div class="block"></div>
</div>
</div>
</div>
if you want less space between the columns you can simply override Bootstrap col-md-* class by adding a class on the columns changing the padding left and right.
First of all, you need to follow proper wrapping of rows and columns. If you want consistency you need to make sure all columns are wrapped into a row.
<div class="row">
<div class="col-md-8 leftSide">
<div class="row">
<div class="col-md-12">
</div>
</div>
<div class="row">
<div class="col-md-12">
</div>
</div>
</div>
<div class="col-md-4 rightSide">
<div class="row">
<div class="col-md-12">
</div>
</div>
</div>
</div>
Then apply custom margins and styling to elements inside of the columns, not columns themselves.
http://www.bootply.com/g6eLHRd1tH

How do I make items in same row appear in same row, different columns - skeleton boilerplate

I am just beginning to learn to code. I am using Skeleton boilerplate to build a responsive template. I am struggling to understand, how to make two items appear on the same row. below is my code for this.
<div class="header">
<div class="container"
<div class="row">
<div class="three.columns"><img src="/image/file">
</div>
<div class="nine.columns">Headline</div>
</div>
</div>
`
">" is missing from the container div.
This would be the correct code:
<div class="header">
<div class="container">
<div class="row">
<div class="three columns"><img src="/image/file"></div>
<div class="nine columns">Headline</div>
</div>
</div>
</div>

Bootstrap Dynamic Layout Change

I am currently using bootstrap on a website which is displaying an ecommerce store.
The current layout is 3 columns of items within 4 rows, but I am wanting to implement a button which will change it to 2 columns.
I have done so, however the code seems to be causing some issues in that the layout changes to
Two Items
One Item
Two Items
One Item
Each one Item row has a large area of white space where an item could go.
The Code below shows one "Row" which is in the three column layout. I have used javascript which changes the class 'col-sm-4' to 'col-sm-6'. Where is my mistake here?
<div class="row"><!-- row 2 -->
<div class="col-sm-4 product-category-display">
<div class="row">
<img src="assets/img/products/women/jackets_coats/raina_parka.png" class="product-image">
</div>
<div class="row product-status">
<span class="products-status-sale">Sale</span>
</div>
<div class="row">
<p class="product-name col-sm-12"<p>Raina Waterproof Parka</p>
</div>
<div class="row product-price">
<span>£99.00</span>
</div>
</div>
<div class="col-sm-4 product-category-display">
<div class="row">
<img src="assets/img/products/women/jackets_coats/april_jacket.png" class="product-image">
</div>
<div class="row product-status">
<span></span>
</div>
<div class="row">
<p class="product-name col-sm-12">April Waterproof Front Pocket Jacket</p>
</div>
<div class="row product-price">
<span>£99.95</span>
</div>
</div>
<div class="col-sm-4 product-category-display">
<div class="row">
<img src="assets/img/products/women/jackets_coats/free_delivery.png" class="product-image">
</div>
<div class="row product-status">
<span></span>
</div>
<div class="row">
<p></p>
</div>
<div class="row product-price">
<span></span>
</div>
</div>
</div><!-- end row 2 -->
The columns should only add upto 12. When you change 4 to 6 its becomes 18.
<div class="row">
<div class="col-lg-4"></div><div class="col-lg-4"></div><div class="col-lg-4"></div>
</div>
Problem solved. I just had to remove all of the rows and tweak the JS to add the class

Spans add up to 12 but won't fit in row bootstrap

I am really struggling with twitter bootstrap. I have the following spans, which add up to 12, yet the thrid item appears on a separate line.
<div class="container">
<div class="row">
<div class="span6 offset6">
<div class="span2">Contact</div>
<div class="span2">About Us</div>
<div class="span2">Blog</div>
</div>
</div>
</div>
Here is what I get...
Your typo is span 6, it should be span6
<div class="span 6 offset6">
Should be:
<div class="span6 offset6">
Not doing so will place a small div to the left of your three span3's, thus moving them a bit sideways.
Updated: You will need to place the div's in their seperate row or row-fluid div's to align them properly.
<div class="row">
<div class="span6 offset6"></div>
</div>
<div class="row">
<div class="span3"></div>
<div class="span3"></div>
<div class="span3"></div>
</div>