Side bar has undefined height and misplaced image - html

I'm sure I'm overcomplicating this in my head, but is the following layout possible using the standard bootstrap 3 grid system?
Header and sub header can fill 12 columns. Then Image, probably fixed height, spans 8-col then a side bar which spans 4-col. The problem is the side bar has an undefined height and the underneath of the image is content.
So far got something like:
<div class="col-xs-12">
<h1>Header</h1>
</div>
<div class="row">
<div class="col-md-8">
image
</div>
<div class="col-md-4">
Navigation down right
</div>
<div class="col-sm-8">
Content
</div>
</div>
Layout

According to your image
You should use the following layout (Click the "Full page" button to see it in action. Also, ignore the CSS. It's just for testing purposes):
#import url(https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css);
[class*='col-'] > div:not(.row) {
background: #DDD;
margin: 0.25em 0;
padding: 0.5em;
text-align: center;
height: 5em;
}
.red [class*='col-'] > div:not(.row) {
background: #C55;
color: #FFF;
height: auto;
}
[class*='col-sm-4'] > div:not(.row) {
height: 9em;
}
<div class="container">
<div class="red row">
<div class="col-sm-12">
<div>HEADER</div>
</div>
<div class="col-sm-8">
<div>SUB HEADER</div>
</div>
</div>
<div class="row">
<div class="col-sm-8">
<div class="row">
<div class="col-sm-12">
<div>IMAGE</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div>LEFT COL</div>
</div>
<div class="col-sm-6">
<div>RIGHT COL</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div>SIDEBAR</div>
</div>
</div>
</div>
Essentially you want a nested row with 6 wide columns for a 12 column grid layout.

Bootstrap row has only twelve spans. I see that 8 + 4 + 8 = 20 > 12, so the "content" div will be at a new line...
And you can't put col-sm-x with col-md-x in the same row...
My suggestion: split into two rows
<div class="col-xs-12">
<h1>Header</h1>
</div>
<div class="row">
<div class="col-md-8">
image
</div>
<div class="col-md-4">
Navigation down right
</div>
</div>
<div>
<div class="col-sm-8">
Content
</div>
</div>
But If you want all of it in the same row:
<div class="col-xs-12">
<h1>Header</h1>
</div>
<div class="row">
<div class="col-md-5">
image
</div>
<div class="col-md-2">
Navigation down right
</div>
<div class="col-md-5">
Content
</div>
</div>
And if you want a side section, you can cascade rows:
<div class="col-xs-12">
<h1>Header</h1>
</div>
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-md-12">
Image
</div>
</div>
<div class="row">
<div class="col-md-12">
Content
</div>
</div>
</div>
<div class="col-md-4">
Navigation down right
</div>
</div>

Related

Bootstrap, allowing content to be responsive/flexible regardless of html layout

So I have a "mostly" functional system that works right now as a CMS: The user goes into an editor and chooses from one of four templates. Within the template they click on a section where they can add images, text or both.
I have a preview screen that shows them what they're making but the issue is that they can create something here where it looks like the image is fitting the space but when it's saved and shown on a huge display it creeps to the top and has a ton of white space below.
So I'm using TinyMCE and when the user saves the info it's saved as HTML in the database, and on my display page (code below) I have that database-driven html coming through a JSON object.
My thing is this: How can I use existing Bootstrap to make sure that regardless of which layout I'm using below (either full width, 2 half width, or a half width with 2 quarter-height half divs) the content within can be more responsive and flexible? I'm trying to get the displayed content to match more closely to what they see on the editor so that regardless of what computer they use to make it, it will be more responseive on the display
This is all of my css and html
html,
body {
height: 100vh;
width: 100vw;
overflow: hidden;
}
iframe{
height:100% !important;
width:100% !important;
}
.middle p{
max-height:100%;
}
.my-container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width:100vw;
}
.my-container>.top [class^="col-"],
.my-container>.bottom [class^="col-"] {
background-color: #778899 ;
color: white;
text-align: center;
}
.my-container>.middle {
flex-grow: 1;
padding:30px;
/*background-image: url('images/bg_green.svg');*/
background-size: cover;
}
.my-container>.middle>* {
}
<div class="container-fluid my-container d-flex h-100">
<div class="row top">
<?php include 'banner.php'?>
</div>
<div class="row middle" id="middle" style="background-image: url();">
<!-- Full Page Divs -->
<div class="col-lg-12" id="fullColumn">
<div class="fullContent" id="fullContent" style="height: 100%; ">
</div>
</div>
<!-- End Full Page Divs -->
<!-- Half Page Divs -->
<div class="col-lg-6 leftColumn " id="leftColumn" style="align-items: center;">
<div class="leftContent" id="leftContent" style=" margin:auto; height: 100%; ">
</div>
</div>
<div class="col-lg-6 rightColumn" id="rightColumn">
<div class="rightContent" id="rightContent" style=" height: 100%; ">
</div>
</div>
<!-- End Half Page Divs -->
<!-- Quarter Page Divs -->
<!-- Left -->
<div class="col-lg-6" id="leftColumnQtr">
<div class="row" style="height:50%; padding-bottom: 15px;">
<div class="col-lg-12" style="height:100%;">
<div id="topLeftContent" style=" height: 100%; ">
</div>
</div>
</div>
<div class="row" style="height:50%; padding-top: 15px;">
<div class="col-lg-12" style="height:100%;">
<div id="bottomLeftContent" style=" height: 100%;">
</div>
</div>
</div>
</div>
<div class="col-lg-6" id="rightColumnQtrHalf" >
<div id="rightQtrContent" style=" height: 100%; ">
</div>
</div>
<!-- right -->
<div class="col-lg-6" id="rightColumnQtr">
<div id="leftQtrContent" style="height: 100%;">
</div>
</div>
<div class="col-lg-6" id="leftColumnQtrHalf" >
<div class="row" style="height:50%; padding-bottom: 15px;">
<div class="col-lg-12" style="height:100%;">
<div id="topRightContent" style=" height: 100%;">
</div>
</div>
</div>
<div class="row" style="height:50%; padding-top: 15px;">
<div class="col-lg-12" style="height:100%;">
<div id="bottomRightContent" style=" height: 100%;">
</div>
</div>
</div>
</div>
<!-- End Quarter Page Divs -->
</div>
<!-- End Row Middle -->
<div class="row bottom">
<?php include 'ticker.php';?>
</div>
</div>
Here's a solution based on what I could get about what you wanted. One thing I'd Strongly recommend is not setting width and height before the initial layout is structured. once the skeleton is ready you can start messing with it.
NOTE: I used bootstrap 4.2.1 for testing this.
"//maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
-- SOLUTION --
I removed all your styles to make things simpler, the styles below are for display purpose only. Feel free to play with it.
<style>
div {
background-color: #00333333;
margin: 0;
padding: 5px;
min-height: 20px;
}
div.row {
background-color: #ff000033;
}
</style>
HTML code
<div class="container-fluid">
<div class="row top">
<h2>something in top</h2>
</div>
<div id="middle">
<div class="row">
<!-- Full Page Divs -->
<div class="col-sm-12">
<h1> FULL PAGE </h1>
</div>
</div>
<!-- End Full Page Divs -->
<!-- Half Page Divs -->
<div class="row">
<div class="col-sm-6">
<h1> left half </h1>
</div>
<div class="col-sm-6">
<h1> right half </h1>
</div>
</div>
<!-- End Half Page Divs -->
<!-- Quarter Page Divs -->
<!-- Left -->
<div class="row">
<div class="col-sm-6" id="leftColumnQtr">
<div class="row">
<div class="col-sm-12">
<h1>topLeftContent</h1>
</div>
<div class="col-sm-12">
<h1>bottomLeftContent</h1>
</div>
</div>
</div>
<div class="col-sm-6" id="rightColumnQtrHalf">
<div class="col-sm-12">
<h1>Right half</h1>
</div>
</div>
</div>
<!-- right -->
<div class="row">
<div class="col-sm-6" id="rightColumnQtrHalf">
<div class="col-sm-12">
<h1>Left half</h1>
</div>
</div>
<div class="col-sm-6" id="leftColumnQtr">
<div class="row">
<div class="col-sm-12">
<h1>top right Content</h1>
</div>
<div class="col-sm-12">
<h1>bottom right Content</h1>
</div>
</div>
</div>
</div>
<!-- End Quarter Page Divs -->
<!-- BONUS: may be this is what you wanted too -->
<div class="row">
<div class="col-sm-6">
<div class="row">
<div class="col-sm-6">
<div class="col-sm-12">
<h1>top Left Content</h1>
</div>
<div class="col-sm-12">
<h1>bottom Left Content</h1>
</div>
</div>
<div class="col-sm-6" id="rightColumnQtrHalf">
<div class="col-sm-12">
<h1>Right half</h1>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="row">
<div class="col-sm-6">
<div class="col-sm-12">
<h1>Left half</h1>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-12">
<h1>top right Content</h1>
</div>
<div class="col-sm-12">
<h1>bottom right Content</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End Row Middle -->
<div class="row bottom">
<h2>something in bottom</h2>
</div>
</div>
Let me know if this is what you intended.

Bootstrap 4 row & column stacking vertically instead of horizontally

I feel like this should be easy, but I'm trying to get my .temp and .city divs to be side-by-side, but they're stacking vertically instead.
I've tried changing the size of the columns, but they always stack on top of each other. Any ideas?
<div class="col-lg" id="col2">
<div class="row">
<div class="col-lg">
<div class="wind"></div>
</div>
</div>
<div class="row">
<div class="col-lg" id="col3">
<div class="temp"></div>
<div class="city"></div>
</div>
</div>
</div>
You can wrap temp div and city div into 2 different columns. Check this Bootstrap4 Example.
.wind,
.temp,
.city {
height: 50px;
border: 1px solid red;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-sm" id="col2">
<div class="row">
<div class="col-lg">
<div class="wind"></div>
</div>
</div>
<div class="row">
<div class="col-lg" id="col3">
<div class="temp"></div>
</div>
<div class="col-lg" id="col3">
<div class="city"></div>
</div>
</div>
You can rearrange your html code to this format.
<div class="row">
<div class="col-lg" id="col2">
<div class="col-lg">
<div class="wind"></div>
</div>
</div>
<div class="col-lg" id="col3">
<div class="temp"></div>
<div class="city"></div>
</div>
</div>
You should edit your code to this, making the second row have two columns.
<div class="col-lg" id="col2">
<div class="row">
<div class="col-lg">
<div class="wind"></div>
</div>
</div>
<div class="row">
<div class="col temp"></div>
<div class="col city"></div>
</div>
</div>

How can achieve in bootstrap 3 a layout with a row spanning tow rows and a column spanning two columns

I want to achieve something like this
So, in the image , A is occupying two rows and B is occupying two columns
I tried, something like this, but as you can see, the logo is never
two column wide, because it is inside a nested row, so it never looks aligned , it always looks shorter or larger
.row{
border:1px solid red;
}
.row div{
min-height: 100px;
border:1px solid black;
}
<div class="container-fluid">
<div class="row upper-row">
<div class="col-md-7" id="">
<div class="row">
<div class="col-md-12">
x
</div>
</div>
<div class="row">
<div class="col-md-8">
s
</div>
<div class="col-md-4">
LOGO
</div>
</div>
</div>
<div class="col-md-5" id="">
A
</div>
</div>
<div class="row bottom-row">
<div class="col-md-5" id="">
</div>
<div class="col-md-7" id="">
B
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-md-12">
</div>
</div>
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6">
</div>
</div>
</div>
<div class="col-md-4">
A
</div>
</div>
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-8">
B
</div>
</div>

How to overlap panel from one row to another row?

I have these panels inside different rows. To easily show my problem, and my desired output, here's a visual...
At the left side is the problem I encounter, and at the right side is the desired output. I was wondering how it's possible to make the right panel overlap to the other row.
My html's structured something like this, which is all inside a .container-fluid(if that contributes to the problem)...
<div class="row">
<div class="col-md-6">
<div class="panel"> <!-- top-left panel --> </div>
</div>
<div class="col-md-6">
<div class="panel"> <!-- right panel --> </div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel"> <!-- bottom-left panel --> </div>
</div>
</div>
I'm using bootstrap.
p.s. sorry for the html "sample", not familiar yet on how to use the html snippet
Use flex
.flex{
display:flex;
}
.flex-1{
flex:1;
}
.height-50{
height:50px;
}
.margin-r-15{
margin-right:15px;
}
.border-1px{
border:1px solid black;
}
<div class="flex">
<div class="flex-1 margin-r-15">
<div class="height-50 border-1px" >
</div>
<div class="height-50 border-1px">
</div>
</div>
<div class="flex-1 border-1px">
</div>
</div>
You can code left div's in one wrapper and right one in another.
HTML
<div class="row">
<div class="col-md-6">
<div class="panel">
//top left panel
</div>
<div class="panel">
// bottom left panel
</div>
</div>
<div class="col-md-6">
<div class="panel">
// right panel
</div>
</div>
</div>
According to your visual above html will be fine but heights are not managed in this.
If you wish to have same height of right box according to left main box then use follwing code
HTML
<div class="row main">
<div class="col-md-6 inner">
<div class="panel">
//top left panel
</div>
<div class="panel">
// bottom left panel
</div>
</div>
<div class="col-md-6 inner">
<div class="panel">
// right panel
</div>
</div>
</div>
CSS
.main{
display:flex;
}
Please try like this:
<div class="row">
<div class="col-md-8">
<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-3">
<div class="row">
<div class="col-md-12"></div>
</div>
</div>
</div>
Please try this:
<div class="row">
<div class="col-lg-8 col-md-8 col-xs-12 col-s-12">
<div class="col-lg-12 col-md-12">
//Your Content Here
</div>
<div class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
//Your Content Here
</div>
</div>
<div class="col-lg-4 col-md-4 col-xs-12 col-sm-12">
<div class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
//Your Content Here
</div>
</div>
</div>
If you can use separate columns (as shown in Gaurav's answer) that will work. If the height of the panels is unknown (variable) here isn't really a simple way. Another option is to put all your cols in a single row and use CSS3 column-width..
.row {
-moz-column-width: 50em;
-webkit-column-width: 50em;
-moz-column-gap: .1em;
-webkit-column-gap: .1em;
}
.col-md-6 {
float:none;
display: inline-block;
margin: .1em;
width: 100%;
}
http://www.bootply.com/6ynLAwenzq

Align three divs in center

I've following layout in bootstrap- fluid layout
<div class="container">
<div class="row-fluid">
<div class="span3 offset1"> </div>
<div class="span3"> </div>
<div class="span3"> </div>
</div>
</div>
My problem is i want to align all the three spans perfectly center aligned
As i am using fluid layout...in full screen above layout is perfectly aligned centre as i've applied fixed offset for the first div
But as it gets smaller in width. all the above 3 div's are not being perfectly aligned in center, as offset is fixed.
I think, here is what happening.....
in bootstrap we have 12 colums, all columns occupying 9 spans..remaining are 3 spans (odd)
because of that odd number i am not able to leave even spans on both sides.....
is there any solution for this?.....
Bootstrap's spans are floated to the left. You can override this behavior by using this:
<div class="container">
<div class="span9" style="float: none; margin-left: auto; margin-right: auto">
<div class="row-fluid">
<div class="span4">... </div>
<div class="span4">... </div>
<div class="span4">... </div>
</div>
</div>
</div>
There should be a row in there.
<div class="container">
<div class="row-fluid">
<div class="span3 offset1"> </div>
<div class="span3"> </div>
<div class="span3"> </div>
</div>
</div>
A non-bootstrap way to solve this:
<div class="container">
<div style="width: 80%; margin: 0 auto;">
<div class="row-fluid">
<div class="span3 offset1"> </div>
<div class="span3"> </div>
<div class="span3"> </div>
</div>
</div>
</div>
The width of the new element can be max-width with a static width aswell.
Like this
<div class="row-fluid">
<div class="span3 offset1"> </div>
<div class="span3"> </div>
<div class="span3"> </div>
</div>
<div class="container">
instead of :
<div class="row-fluid">
i think click on this below link duplicate question
Is it possible to horizontally center align a row of bootstrap spans that don't add up to 12?