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/
Related
I'm working on a site which needs an image centered in the div on the left side, centered off the right div with a background.
I tried to a common solution, but for some reason, it won't work. It must be responsive as well, so I'm a bit in the dark over here. See my fiddle for the example.
<div class="container-fluid">
<div class="row">
<div class="col-12 col-sm-6">
<div class="leftSide">
<img src="https://images.pexels.com/photos/3755760/pexels-photo-3755760.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="img-fluid imgLeft">
</div>
</div>
<div class="col-12 col-sm-6">
<div class="rightSide">
<h3>
Some text
</h3>
<p>
Some more text
</p>
<button type="button" class="btn btn-primary">Some text</button>
</div>
</div>
https://jsfiddle.net/Onno0297/grvwxby2/1/
If I understand your question correctly then below code will work.
Visit https://jsfiddle.net/alishapatel/n3ap1vjo/4/!
.leftSide {
height: 100%;
display: flex;
align-items: center;
}
.rightSide {
background: #313131;
height: 546px;
color: #fff;
}
.rightSide h3 {
text-align: center;
padding-top: 200px;
}
.rightSide p {
text-align: center;
}
.btn.btn-primary {
margin: 0 auto;
display: block;
}
.imgLeft {
max-height: 400px;
max-width: 300px;
margin: 0 auto;
width: 100%;
}
<div class="container-fluid">
<div class="row">
<div class="col-12 col-sm-6">
<div class="leftSide">
<img src="https://images.pexels.com/photos/3755760/pexels-photo-3755760.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" class="img-fluid imgLeft">
</div>
</div>
<div class="col-12 col-sm-6">
<div class="rightSide">
<h3>
Some text
</h3>
<p>
Some more text
</p>
<button type="button" class="btn btn-primary">Some text</button>
</div>
</div>
</div>
</div>
I am trying to design something but even on adding the margin property I am not able to see the changes.
Below is my html code.
.side {
background-color: teal;
display: inline;
padding: 7px;
margin-top: 20px;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
Use display: inline-block; instead of just display: inline;, because margin-top and margin-bottom does not work with inline elements
.side {
background-color: teal;
display: inline-block;
padding: 7px;
margin-top: 20px;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
You could either try this or change inline to block or inline-block
.side {
background-color: teal;
display: inline;
padding: 7px;
line-height: 400%;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
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 am trying to achieve this:
I want the three panels in the gray <div> to overlap with the white jumbotron above them. How can I do this in CSS or with Bootstrap?
HTML:
<div id="home-page">
<div class="container text-center">
<div class="row">
<div class="col-sm-4">
<div class="panel">
</div>
</div>
<div class="col-sm-4">
<div class="panel">
</div>
</div>
<div class="col-sm-4">
<div class="panel">
</div>
</div>
</div>
</div>
<div class="container">
<h3>Passionate About Technology?</h3>
<p>We make and effort to learn something everyday</p>
LEARN
</div>
</div>
CSS
#home-page { background: #EFEFEF; }
#home-page .panel { box-shadow: 0px 0px 10px gray; margin: 15px; }
Thanks!
I was able to replicate the pic you had with a few adjustments to your code:
here is the css:
#home-page {
background: #EFEFEF;
}
#home-page .panel {
box-shadow: 0px 0px 10px gray;
margin: 15px;
margin-top:-50px;
height:200px;
}
#jumbo{
height:100px;
}
I also added a div on top to get that effect
<div id="jumbo"></div>
please see my codepen
http://codepen.io/sammyb123/pen/dMJaRw
View below snippet in Full page. If you want the same effect on smaller devices then use col-xs instead.
#home-page .panel {
box-shadow: 0px 0px 10px gray;
height: 250px;
margin-top: -15px;
}
#home-page .jumbo-ctr {
background: #fff;
margin-bottom: 20px;
}
#home-page .panel-ctr {
background: #EFEFEF;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div id="home-page">
<div class="container jumbo-ctr">
<h3>Passionate About Technology?</h3>
<p>We make and effort to learn something everyday</p>
LEARN
</div>
<div class="container-fluid text-center panel-ctr">
<div class="row">
<div class=" col-sm-offset-3 col-sm-2 ">
<div class="panel">
</div>
</div>
<div class="col-sm-2 ">
<div class="panel">
</div>
</div>
<div class="col-sm-2 ">
<div class="panel"></div>
</div>
</div>
</div>
</div>
Need some help with centering a block of images. Here is an image of how I want it to look like. I've tried margin: 0, auto; and having various margins but it doesnt seem to work.
Any ideas and i would be most grateful!
http://jsfiddle.net/tcd1s7xm/
h1 {
padding-top: 3%;
padding-bottom: 3%;
text-transform: uppercase;
color: #58585B;
font-weight: 500;
text-align: center;
font-size: 24px;
}
p {
max-width: 80%;
min-height: auto;
font-size: 14.5px;
color: #58595B;
line-height: 2em;
font-weight: 300;
text-align: center;
letter-spacing: 0.05em;
display: block;
margin-left: auto;
margin-right: auto;
text-transform: uppercase;
}
.break {
padding-bottom: 3%;
}
.info-wrap {
background-color: #EDEDED;
}
.info-wrap img {
display: block;
margin-left: auto;
margin-right: auto
}
.work {
}
.posts {
display: inline-block;
}
.work-img {
padding: 0;
}
<div class="work">
<div class="row">
<h1>My Work</h1>
</div>
<div class="posts">
<div class="row">
<div class="large-6 columns work-img"><img alt=
"People Portraits" src="img/people.png"></div>
<div class="large-6 columns work-img"><img alt="Murals"
src="img/murals.png"></div>
</div>
<div class="row">
<div class="large-6 columns work-img"><img alt=
"Animal Portraits" src="img/animal.png"></div>
<div class="large-6 columns work-img"><img alt=
"Canvas Paintings" src="img/canvas.png"></div>
</div>
<div class="row">
<div class="large-6 columns work-img"><img alt="Surface Design"
src="img/surface.png"></div>
<div class="large-6 columns work-img"><img alt=
"Tromp L'oeil" src="img/tromp.png"></div>
</div>
</div>
<div class="break"></div>
Are you using Foundation 5? Because if you are, you should probably nest the images in a large-12 div. And I think there are too many rows. For example you could try:
<div class="posts">
<div class="row">
<div class="large-12">
<div class="large-6 columns work-img"><img alt=
"People Portraits" src="img/people.png"></div>
<div class="large-6 columns work-img"><img alt="Murals"
src="img/murals.png"></div>
</div>
<div class="large-12">
<div class="large-6 columns work-img"><img alt=
"Animal Portraits" src="img/animal.png"></div>
<div class="large-6 columns work-img"><img alt=
"Canvas Paintings" src="img/canvas.png"></div>
</div>
<div class="large-12">
<div class="large-6 columns work-img"><img alt="Surface Design"
src="img/surface.png"></div>
<div class="large-6 columns work-img"><img alt=
"Tromp L'oeil" src="img/tromp.png"></div>
</div>
</div>
</div>
And then maybe try margin: 0 auto on work image in CSS, or if that doesn't work try putting a class on the large-12 by adding the class name in front of large-12, and do the margin: 0 auto. It's kinda difficult without the images in the jsfiddle.
You could try a combination of display: inline-block and text-align: center to achieve what you want.
For example:
HMTL:
<div class="wrapper">
<div class="row">
<div class="image">
<!-- image link and etc -->
</div>
<div class="image">
<!-- image link and etc -->
</div>
</div>
<div class="row">
<div class="image">
<!-- image link and etc -->
</div>
<div class="image">
<!-- image link and etc -->
</div>
</div>
<div class="row">
<div class="image">
<!-- image link and etc -->
</div>
<div class="image">
<!-- image link and etc -->
</div>
</div>
</div>
CSS:
.wrapper {
text-align: center;
}
.wrapper .row {
display: inline-block
}