How to make a div not break when resizing browser - html

Guys I have three divs in this setup: I'm not sure if you're familiar with this bootstrap css but i should give it a try:
<div class="row-fluid">
<div class="span4"> A graph here </div>
<div class="span4"> A graph here </div>
<div class="span4"> A graph here </div>
</div>
<div class="row-fluid">
<div class="span4"> Another graph here </div>
<div class="span4"> Another graph here </div>
<div class="span4"> Another graph here </div>
</div>
span4 will make the three divs fit to the whole page proportionally. So the position is the three graphs will position each other to the top div side by side, and another three graphs below it.
My problem is, when i resize the browser window, the graphs will be under each other vertically, like they have their own container now. How to make those graphs, retain their side by side position?

you can do the following:
<div class="row-fluid">
<div class="third"> A graph here </div>
<div class="third"> A graph here </div>
<div class="third"> A graph here </div>
</div>
<div class="row-fluid">
<div class="third"> Another graph here </div>
<div class="third"> Another graph here </div>
<div class="third"> Another graph here </div>
</div>
and css:
.third{
float:left;
width:33.33%;
}

You need to put them in divs like so -
<div class="row">
<div class="col-xs-4">
graph1
</div>
<div class="col-xs-4">
graph2
</div>
<div class="col-xs-4">
graph3
</div>
</div>
Each rows divs should add up to 12 to fill that row completely. Where the col-X is on your div class= represents when your divs will stack vertically instead of horizontally. So if you had col-sm-4 your divs would stack vertically on the bootstrap "small" resolution media query. By setting them as col-xs-4 each row will stay horizontal on the small resolutions.
Also check out these resources
Bootstrap official documentation
Understanding BootStrap grid system for beginners

Related

Controlling the relative height of divs in relation to its neighbor with bootstrap

I am working on a layout where I have three divs on a page. Image below is a rough diagram of the layout as it currently sits. My question is how would I scale one div to match the height of two stacked divs next to it on a page?
I'm working with bootstrap.
The div to the right, would be the div that would scale to the total height of the two divs to the right.
Your tags say you're using Bootstrap 4. I would suggest that you start by nesting cols and optionally using flex-based classes to style things up where needed:
<div class="container">
<div class="row">
<div class="col-4 sidebar">
<p>Sidebar</p>
</div>
<div class="col">
<div class="row">
<div class="col-12 content">
<p>Content</p>
</div>
<div class="col-12 content">
<p>More content</p>
</div>
</div>
</div>
</div>
</div>
CodePen of the above.

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

Bootstrap griding system ideas

Is there any way that i achieve this design but still using the bootstrap griding system?
I want to make that design. In the sides of the div there should be an accordion like div so that i can click to close the div. I tried using col-md-5 but the grid is to much space just for side panel like. I just want a small div in right side and left side.
What about putting the text <div> inside the <div class="col-md-6">
It would be something like this :
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-1">
<!-- text -->
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-offset-11 col-md-1">
<!-- text -->
</div>
</div>
</div>
</div>
</div>

Stacked Div in the same row

I'm wondering what is the best way to stack a div? Would I be best off using the div class table? Here is my code
<div class="row">
<div class="col-md-5 content1">
[rotatingtweets screen_name='lauterbachgroup']
</div>
<div class="col-md-4 content2">
<p>Gallery</p>
</div>
<div class="col-md-3 content3">
<p>content3</p>
</div>
<div class="col-md-5 content4">
<p>content4</p>
</div>
</div>
I am trying to get the last content box to flow underneath the first box. I think I may be overthinking it but I have a couple more things I would like to try but, any advice would be great.

Offset vertical position of div elements within Twitter Bootstrap

I'm attempting to correctly vertically align offsetting elements using Twitter Bootstrap with a fluid grid. (Note: Grid is customized to 30 columns)
Considering the red boxes, this is the attempted div placement: http://imgur.com/IkB2G
This is the current actual placement with my code: http://imgur.com/oJ2mG
Here is the code I am using. Unsure how to get the lower red box to move into the empty space above it, per the images.
<div class="container-fluid nomargin">
<div class="row-fluid span30 nomargin"><div style="height:10px"></div></div> <!-- Vertical spacing between menu and content-->
<div class="row-fluid">
<div class="span4"></div>
<div class="span16 white-box">
<!--Body content-->
<div style="height:100px"></div>
</div>
<div class="span6 white-box">
<!--Body content-->
<div style="height:300px"></div>
</div>
<div class="span16 white-box">
<!--Body content-->
<div style="height:100px"></div>
</div>
</div>
You need to think of it as 2 columns, and in the left column you have nested rows. I can't make out the proper sizes from the code you posted. But hopefully this code will give you some inspiration.
<div class="row">
<div class="span18">
<div class="row">
<div class="span18">This is a row on the left side.</div>
</div>
<div class="row">
<div class="span18">This is a row on the left side.</div>
</div>
</div>
<div class="span12">
This is the content on the right side.
</div>
</div>