OK Im using bootstrap and i have main content and inside main content i have left and right side. On left side its content and on right side i have 8 boxes. I tried everything but i cant get equal left and right side.
.main-content{
float: left;
width: 100%;
position: relative;
}
.main-content .right-box.col-md-4{
width: 37.5%;
padding-left:0;
padding-right:0;
float:right;
position:absolute;
top:0;
bottom:0;
right: 0;
}
.main-content .left-box.col-md-8{
width:62.5%;
padding-left:0;
padding-right: 0;
background-color: #fff;
float: left;
position: relative;
}
FIDDLE: https://jsfiddle.net/rvqg3fd7/
and last div on right side need to be same height like div on left side..
I tried this but without succes.
Height is an element you shouldn't force in a Bootstrap powered website, simply because Bootstrap relies on it's vertical flexibility to respond to smaller devices. After all, this is the main purpose why anyone would use Bootstrap. Yet, if you do insist, then you must give each element a definite height and control such height with paddings.
You didn't provide a code we could use (not even the fiddle) so I'll post my demo so you can see the bootstrap classes architecture you need to achieve this;
Here is the HTML
<div class="container">
<div class="row main-content">
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="row">
<div class="box left">
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="row">
<div class="box right">
<div class=" innerbox col-xs-12">
1
</div>
<div class=" innerbox col-xs-12">
2
</div>
<div class=" innerbox col-xs-12">
3
</div>
<div class=" innerbox col-xs-12">
4
</div>
<div class=" innerbox col-xs-12">
5
</div>
<div class=" innerbox col-xs-12">
6
</div>
<div class=" innerbox col-xs-12">
7
</div>
<div class=" innerbox col-xs-12">
8
</div>
</div>
</div>
</div>
</div>
</div>
And the CSS
.box.left{
background:red;
text-align:center;
color: white;
height:350px;
}
.box.right{
background:blue;
text-align:center;
color: white;
height:350px;
padding:10px
}
.innerbox{
background:lightgray;
text-align:center;
color: black;
height:30px;
margin-top:10px;
}
.main-content{
float: left;
width: 100%;
position: relative;
}
And the link to the DEMO
Related
What is the way of making div's have equal heights within the row?
it says everywhere that bootstrap4 is flex by default, but it doesn't work for some unknown reason
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="content" >
<div class="sub_title"> HISTORY </div>
<div class="desc"> Sometext </div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-6 col-md-6 col-lg">
<div class="content">
<div class="sub_title">
<div class="number"> 2012 </div>
</div>
<div class="desc"> some other text </div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6 col-lg ">
<div class="content">
<div class="sub_title">
<div class="number"> 2014 </div>
</div>
<div class="desc"> More text </div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6 col-lg ">
<div class="content">
<div class="sub_title">
<div class="number"> 2017 </div>
</div>
<div class="desc"> Text here too </div>
</div>
</div>
</div>
the scss
.content {
#extend .effect8;
background: white;
margin: 10px;
padding: 10px 30px 20px;
span {
display: block;
p {
font-weight: bold;
}
}
}
.sub_title {
font-size: 1.5em;
font-weight: 700;
text-transform: uppercase;
display: block;
color: $blue;
margin: 10px auto;
}
this is the scss for the content and the sub_title class
If you want .content to be full height on each .col, the content should have height:100%;. I don't know the CSS def of .effect8.
.content {
background: white;
margin: 10px;
padding: 10px 30px 20px;
height: 100%;
span {
display: block;
p {
font-weight: bold;
}
}
}
https://www.codeply.com/go/B4g6TlSDkA
Actually it depend of browser, e.g In Safari it may not work, and also in Internet Explorer may have unwanted behaviors.
If you're really want equal and avoid cross browser issue try JS solution e.g http://brm.io/jquery-match-height/
Having troubles aligning these columns inside a section column.
Here is a screenshot of what's happening: https://gyazo.com/cfe7bfa58e98226d8e1718792631c035
And here's jsfiddle with all the required code: https://jsfiddle.net/8xxgn8vr/
<!-- Testimonials Section -->
<section id="testimonials" class="testimonials-section">
<div class="container testimonials-container center-block">
<div class="row">
<div class="col-lg-12">
<h1 class="">Testimonials</h1>
<div class="col-lg-12">
<div class="col-lg-6 testimonials">
Review 1
</div>
<div class="col-lg-6 testimonials">
Review 2
</div>
<div class="col-lg-6 testimonials">
Review 3
</div>
<div class="col-lg-6 testimonials">
Review 4
</div>
</div>
</div>
</div>
</div>
</section>
.container.testimonials-container {
margin: 0 50px 0 50px;
width: auto;
}
.col-lg-6.testimonials {
background: #E5E4DF;
height: 500px;
padding: 25px;
width: 300px;
margin: 50px 25px 50px 25px;
}
.testimonials-section {
background: #F6F6F6;
height: 100%;
padding-top: 40px;
text-align: center;
}
It's basically a section for reviews in index.html page and inside the section there will be 4 reviews which I want to be aligned in the center.
Thanks for all the help in advance.
Since you're using bootstrap I would suggest not altering directly the width of the grid elements, when you get a col-lg-6 that is supposed to occupy half of a row and set it to be 300px, you will be throwing away bootstrap responsiveness and it will eventually give you a hard time adjusting to the other specifics of the col-lg-6 class.
Since you mentioned you wanted to have 4 reviews all centered you could perhaps change your code to use a col-lg-3 that divides the row into 4 equal parts. Check this updated fiddle, but it would go like this:
HTML:
<!-- Testimonials Section -->
<section id="testimonials" class="testimonials-section">
<div class="container testimonials-container center-block">
<div class="row">
<div class="col-md-12">
<h1 class="">Testimonials</h1>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="testimonials">
Review 1
</div>
</div>
<div class="col-md-3">
<div class="testimonials">
Review 2
</div>
</div>
<div class="col-md-3">
<div class="testimonials">
Review 3
</div>
</div>
<div class="col-md-3">
<div class="testimonials">
Review 4
</div>
</div>
</div>
</div>
</section>
Updated CSS:
.container.testimonials-container {
margin: 0 50px 0 50px;
width: auto;
}
.testimonials {
background: #E5E4DF;
height: 500px;
padding: 25px;
margin: 50px 25px 50px 25px;
}
.testimonials-section {
background: #F6F6F6;
height: 100%;
padding-top: 40px;
text-align: center;
}
You are trying to fit 4 sections of lg-6 into a row of lg-12. Bootstrap is a grid system based on 12 parts. If you want the parts to align you always need to think about the 12 sections.
If you have only 4 reviews, you have to make sure you are using 12 divide by 4 = 3, so you need lg-3.
If you have less than 4 parts but you still want them to take space of 4 parts you'll have to intervene with bootstrap. (there is a SO post about aligning a row)
Also in your css you are changing the width of the bootstraps' divs and that's not good. (also margin). Never do that ;)
Example with 4 divs:
(using inner div)
HTML:
<!-- Testimonials Section -->
<section id="testimonials" class="testimonials-section">
<div class="container testimonials-container center-block">
<div class="row">
<div class="col-lg-12">
<h1 class="">Testimonials</h1>
<div class="col-lg-12">
<div class="col-lg-3 testimonials">
<div>
Review 1
</div>
</div>
<div class="col-lg-3 testimonials">
<div>
Review 2
</div>
</div>
<div class="col-lg-3 testimonials">
<div>
Review 3
</div>
</div>
<div class="col-lg-3 testimonials">
<div>
Review 4
</div>
</div>
</div>
</div>
</div>
</div>
</section>
CSS:
.container.testimonials-container {
margin: 0 50px 0 50px;
width: auto;
}
.testimonials div {
height: 500px;
background: #E5E4DF;
padding: 25px;
margin: 50px 25px 50px 25px;
}
.testimonials-section {
background: #F6F6F6;
height: 100%;
padding-top: 40px;
text-align: center;
}
Fiddle
Use the following code:
.col-lg-6.testimonials {
background: #E5E4DF;
height: 500px;
padding: 25px;
width: 300px;
margin: 50px 25px 50px 25px;
display: inline-block;
float: none;
}
You can just add class "row" to the outer column? Works for me in your fiddle.
<div class="row">
<div class="col-lg-12 row">
<h1 class="">Testimonials</h1>
<div class="col-lg-12">
<div class="col-lg-6 testimonials">
Review 1
</div>
<div class="col-lg-6 testimonials">
Review 2
</div>
<div class="col-lg-6 testimonials">
Review 3
</div>
<div class="col-lg-6 testimonials">
Review 4
</div>
</div>
</div>
.testimonials-section {
background: #F6F6F6;
height: 100%;
padding-top: 40px;
text-align: center;
}
.testimonials {
background: #FFFFFF;
}
.testimonials_content{
width: 95%;
margin: 0 auto;
border: thin black solid;
height: 500px;
background: #F5F5F5;
padding: 25px;
text-align: center;
font-size: 16px;
}
<section id="testimonials">
<div class="container testimonials-container">
<div class="row">
<h1>Tetimonials</h1>
<div class="col-lg-3 testimonials">
<div class="testimonials_content">
Review 1
</div>
</div>
<div class="col-lg-3 testimonials">
<div class="testimonials_content">
Review 2
</div>
</div>
<div class="col-lg-3 testimonials">
<div class="testimonials_content">
Review 3
</div>
</div>
<div class="col-lg-3 testimonials">
<div class="testimonials_content">
Review 4
</div>
</div>
</div></div>
</section>
you can't fit 4 sections into lg-6 for that you have to take lg-3. and under it you can take div by giving margin or width as per your need.
hope this helps.
I have a scroll overflow into a hidden one
Fiddle here
The problem is that the page won't scroll so I can see the rest of content, notice that i want the sidebar and the top bar to stay fixed in their place, only the body with the gray color to scroll
html,body{
background-color: #f8f8f8;
height: 100%;
overflow: hidden;
}
/////////////////////////////////////////
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="background- color: #e5e2e6; color:#000000; padding-top: 20px; overflow:scroll;">
test1<br/><br/><br/><br/><br/>
test2<br/><br/><br/><br/><br/>
test3<br/><br/><br/><br/><br/>
test4<br/><br/><br/><br/><br/>
test5<br/><br/><br/><br/><br/>
test6<br/><br/><br/><br/><br/>
</div>
Is it what you want ?
See this fiddle
Remove overflow: hidden; from html, body and then update HTML code like this :
HTML code updated :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body style="background-color: #e5e2e6;" >
<div class="container-fluid" style="height:100%;">
<div class="row" style="height:100%;" align="center">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 sidebar" style="height:100%; position: fixed; z-index: 10;">
<p class="title" style="text-align:center; color:#FFFFFF; font-size:2.6vw;">TITLE</p>
</div>
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9" style="background-color: #3a3633; color:white; z-index: 10; margin-left: 25%; position: fixed; ">
<span class="label label-default pull-left" style="font-size:15px; margin:1%;">TEST</span>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="background-color: #e5e2e6; color:#000000; padding-top: 30px; padding-left: 25%; ">
test1<br/><br/><br/><br/><br/>
test2<br/><br/><br/><br/><br/>
test3<br/><br/><br/><br/><br/>
test4<br/><br/><br/><br/><br/>
test5<br/><br/><br/><br/><br/>
test6<br/><br/><br/><br/><br/>
</div>
</div>
</div>
</div>
</div>
I've added position: fixed; to elements you wanted fixed and add some padding to show content properly
I've changed the grey content :
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="background-color: #e5e2e6; color:#000000; padding-top: 30px; padding-left: 25%; ">
padding-left: 25%; because of the width of the left bar
padding-top: 30px; because of the height of the top bar
The top bar :
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9" style="background-color: #3a3633; color:white; z-index: 10; margin-left: 25%; position: fixed; ">
margin-left: 25%; is the width of the left bar
The left sidebar :
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 sidebar" style="height:100%; position: fixed; z-index: 10;">
The z-index with position: fixed; is used to put on first plan the two fixed bars
FYI
Its not needed to include all of the col-xs col-sm col-md and col-lg if you are going to use same size for the column. e.g. including only col-xs-3 will work for all col-xs-3 col-sm-3 col-md-3 and col-lg-3. And col-sm-9 will work for col-xs-9 col-sm-9 col-md-9 and col-lg-9
You could try using bootstraps built in tools to handle this type of thing. Use class navbar-fixed-top for your top bar, and sidebar-nav for your sidepanel.
I want to align different size images to the bottom of a div but the images are also in their own divs so the other answers don't work.
I have the following HTML:
<div class="row footer-links">
<section>
<div class="col-md-4">
<p>
Proudly presented and sponsored by
</p>
</div>
<div class="col-md-8 col-xs-12 logo-links">
<div class="row logo-bottom">
<div class="col-md-2 col-xs-12 logo-border col-md-offset-1">
<img id="rasv" class="center-block" src="img/rasv.png" alt="RASV logo">
</div>
<div class="col-md-2 col-xs-12 logo-border">
<img class="center-block" src="img/victoria-farmers.png" alt="Victoria Farmers logo">
</div>
<div class="col-md-2 col-xs-12 logo-border">
<img class="center-block" src="img/anz.png" alt="ANZ logo">
</div>
<div class="col-md-2 col-xs-12 logo-border">
<img class="center-block" src="img/pwc.png" alt="PWC logo">
</div>
<div class="col-md-2 col-xs-12 logo-border">
<img class="center-block" src="img/vac.png" alt="VAC logo">
</div>
</div>
</div>
</section>
</div>
I used the following CSS:
.logo-border {
border-right: 1px solid #d1d3d4;
height: 54px;
vertical-align: bottom;
display: table-cell;
}
Here is a Code Pen for more information.
You were really close.
The reason it wasn't working was because the columns are floated. Due to this, the elements weren't behaving like a table-cell, therefore rendering vertical-align: bottom useless.
You could simply add float: none and it will work as desired.
Updated Example
.logo-bottom .logo-border {
border-right: 1px solid #d1d3d4;
height: 54px;
vertical-align: bottom;
display: table-cell;
float: none;
}
As a side note, I increased the specificity of the selector .logo-border to .logo-bottom .logo-border so that float: left was overridden.
I'm trying to split a section of my one-page site (using Bootstrap 3) into 4 equal parts but I can't get it to work.
I thought I could just add extra classes to each col-md-6 but the problem is actually that the height is aligned to the content and I can't use fixed heights because it should be responsive...
<section>
...
</section>
<section id="theproject" class="project">
<div class="container" >
<div class="row">
<div class="col-md-6">
</div>
TOPLEFT
<div class="col-md-6">
TOPRIGHT
</div>
</div>
<div class="row">
<div class="col-md-6">
BOTTOMLEFT
</div>
<div class="col-md-6">
BOTTOMRIGHT
</div>
</div>
</div>
</section>
My custom.css looks like this:
.project {
height: auto !important;
min-height: 100%;
overflow: hidden;
background: white;
font-family: 'Open Sans', sans-serif;
font-style: normal;
font-size: 16px;
}
Thanks for your help!
If I understand what you are asking, here is how you can split your bootstrap into 4 equal parts. The heights will adjust to match the height of the column with the most(tallest) content.
Here is the Bootply so you can try it out.
HTML
<div class="row equal">
<div class="col-xs-6 col-sm-3">
content
</div>
<div class="col-xs-6 col-sm-3">
content
</div>
<div class="col-xs-6 col-sm-3">
content
</div>
<div class="col-xs-6 col-sm-3">
content
</div>
</div>
CSS
.equal, .equal > div[class*='col-'] {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex:1 0 auto;
}
EDITED: Solution for 4 equal quadrants
See the working Bootply here
http://www.bootply.com/qmwjea4pG3#
Example Below
HTML
<div class="contents">
<div class="col-md-6 quarter" style="background-color:blue;">test</div>
<div class="col-md-6 quarter" style="background-color:red;">test</div>
<div class="col-md-6 quarter" style="background-color:yellow;">test</div>
<div class="col-md-6 quarter" style="background-color:green;">test</div>
CSS
html,body {
padding:0;
margin:0;
height:100%;
min-height:100%;
}
.quarter{
width:50%;
height:100%;
float:left;
}
.contents{
height:50%;
width:100%;
}