Podium CSS: position elements at the bottom of their div - html

I'm trying to create a podium using CSS and HTML. I have achieved to positionate the steps of the podium at the bottom by adding position: relative to the father and position: absolute; bottom: 0 to the steps, but as I want to display a text just above the steps, I'm having problems positioning this text there.
My first aproach was to put the text and the step on a div and positioning absolutely this div, but as the steps get their height by a percentage of their father the father needs to have a height: 100% property, so the div solution isn't valid.
Here I attach my code snippet:
#font-face {
font-family: DaggerSquare;
src: url("fonts/podium-font.woff") format("woff"), url("fonts/podium-font.ttf") format("truetype");
}
#podium-box {
width: 100%;
margin: 0 auto;
}
.podium-number {
font-family: DaggerSquare;
font-weight: bold;
font-size: 4em;
color: white;
}
.step-container {
width: 100%;
position: relative;
}
.step {
width: 100%;
position: absolute;
bottom: 0;
}
.bg-blue {
background-color: #063b65;
}
#first-step {
height: 50%;
}
#second-step {
height: 35%;
}
#third-step {
height: 30%;
}
.centerBoth {
display: flex;
justify-content: center;
align-items: center;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="import" type="css" href="podium-chart.css">
<div id="podium-box" class="row" style="height: 400px">
<div class="col-md-4 step-container m-0 p-0">
<div>
Text 2
</div>
<div id="second-step" class="bg-blue step centerBoth podium-number">
2
</div>
</div>
<div class="col-md-4 step-container m-0 p-0">
<div>
Text 1
</div>
<div id="first-step" class="bg-blue step centerBoth podium-number">
1
</div>
</div>
<div class="col-md-4 step-container m-0 p-0">
<div>
Text 3
</div>
<div id="third-step" class="bg-blue step centerBoth podium-number">
3
</div>
</div>
</div>

No need to use position:absolute just use flexbox and flex-columns.
Then push the text div to the bottom.
#font-face {
font-family: DaggerSquare;
src: url("fonts/podium-font.woff") format("woff"), url("fonts/podium-font.ttf") format("truetype");
}
#podium-box {
margin: 0 auto;
display: flex;
}
.podium-number {
font-family: DaggerSquare;
font-weight: bold;
font-size: 4em;
color: white;
}
.step-container {
flex: 1;
display: flex;
flex-direction: column;
}
.step-container>div:first-child {
margin-top: auto;
text-align: center;
}
.step {
text-align: center;
}
.bg-blue {
background-color: #063b65;
}
#first-step {
height: 50%;
}
#second-step {
height: 35%;
}
#third-step {
height: 30%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="import" type="css" href="podium-chart.css">
<div id="podium-box" class="row" style="height: 300px">
<div class="col-md-4 step-container m-0 p-0">
<div>
Text 2
</div>
<div id="second-step" class="bg-blue step centerBoth podium-number">
2
</div>
</div>
<div class="col-md-4 step-container m-0 p-0">
<div>
Text 1
</div>
<div id="first-step" class="bg-blue step centerBoth podium-number">
1
</div>
</div>
<div class="col-md-4 step-container m-0 p-0">
<div>
Text 3
</div>
<div id="third-step" class="bg-blue step centerBoth podium-number">
3
</div>
</div>
</div>

As has already been pointed out, you could probably start from scratch and structure this a bit better. But if you want to keep as is then just give the divs that contain the text a class and give them the following attributes:
position:absolute;
bottom:70px;

Related

displaying block of two divs on half splitted index page

I have a half-splitted index page. I use twitter bootstrap-v5.1.3 to split. On the left side I have two divs which have one text and one image class.
These divs are inside of flex-parent. So they are looking inline-block.
I want text on top and image on bottom which I mentioned below. But also text and image must be on center in "leftside col-md-6".
I need this:
body {
font-family: "Merriweather", sans-serif;
background-color: #fafafa;
overflow-x: hidden;
}
.leftside,
.rightside {
height: 50vh;
width: 100%;
}
#media screen and (min-width: 768px) {
.leftside,
.rightside {
height: 100vh;
}
}
.leftside {
background-color: #8a68ff;
opacity: 83%;
}
.rightside {
background-color: #ffffff;
}
.left-hero-text {
font-size: 48px;
font-weight: 400;
color: #ffffff;
}
.bold-text {
font-size: 55px;
font-weight: 700;
}
img {
width: 50%;
height: auto;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="row gx-0">
<div class="col-md-6 gx-0">
<div class="leftside d-flex justify-content-center align-items-center">
<div class="left-hero-text">
<span class="bold-text">Lorem</span> ipsum
<span class="bold-text">dolor</span> sit amet
</div>
<img src="https://wiki.geogebra.org/uploads/a/a4/Menu-tools.svg" alt="tools" />
</div>
</div>
<div class="col-md-6 gx-0">
<div class="rightside d-flex justify-content-center align-items-center">
Right Side
</div>
</div>
</div>
You just need to change your inner flex container's direction to column.
body {
font-family: "Merriweather", sans-serif;
background-color: #fafafa;
overflow-x: hidden;
}
.leftside,
.rightside {
height: 50vh;
width: 100%;
}
#media screen and (min-width: 768px) {
.leftside,
.rightside {
height: 100vh;
}
}
.leftside {
background-color: #8a68ff;
opacity: 83%;
}
.rightside {
background-color: #ffffff;
}
.left-hero-text {
font-size: 48px;
font-weight: 400;
color: #ffffff;
}
.bold-text {
font-size: 55px;
font-weight: 700;
}
img {
width: 50%;
height: auto;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="row gx-0">
<div class="col-md-6 gx-0">
<div class="leftside d-flex flex-column justify-content-center align-items-center">
<div class="left-hero-text">
<span class="bold-text">Lorem</span> ipsum
<span class="bold-text">dolor</span> sit amet
</div>
<img src="https://wiki.geogebra.org/uploads/a/a4/Menu-tools.svg" alt="tools" />
</div>
</div>
<div class="col-md-6 gx-0">
<div class="rightside d-flex justify-content-center align-items-center">
Right Side
</div>
</div>
</div>

Position Flex Item at Bottom

I am new to HTML and CSS so sorry if this was a simple question. This is a image of what I am trying to achieve
Picture of number of clients and years of experience
And this is what I managed to make
My Question is how do I align the text) to the same level as the number
.experience {
color: orange;
display: flex;
width: 50%;
}
.number {
font-size: 5rem;
}
.number-text {
float: right;
padding-left: 10px;
}
.clients {
color: orange;
display: flex;
width: 50%;
}
<div class="row">
<div class="experience">
<div class="col-lg-auto">
<p class="number">
12
</p>
</div>
<div class="col-lg-auto">
<p class="number-text">Years Of <br> Experience.</p>
</div>
</div>
<div class="clients">
<div class="col-lg-auto">
<p class="number">
14
</p>
</div>
<div class="col-lg-auto">
<p class="number-text">Satisfied <br> Clients.</p>
</div>
</div>
</div>
Your html is far too complex for this and all the other answers are incorrect as they are centering the text rather than aligning it with the bottom of the text. You can do this properly using align-items: last baseline;.
.client {
display: flex;
align-items: last baseline;
}
.number {
font-size: 5rem;
}
.text {
margin-left: 1em;
}
<div class="client">
<div class="number">14</div>
<div class="text">
Years Of <br> Experience.
</div>
</div>
But if you need to use your html then you can do it like this:
.experience, .clients {
color: orange;
display: flex;
width: 50%;
align-items: last baseline;
}
.number {
font-size: 5rem;
}
.number-text {
float: right;
padding-left: 10px;
margin: 0;
}
.clients {
color: orange;
display: flex;
width: 50%;
}
<div class="row">
<div class="experience">
<div class="col-lg-auto">
<p class="number">
12
</p>
</div>
<div class="col-lg-auto">
<p class="number-text">Years Of <br> Experience.</p>
</div>
</div>
<div class="clients">
<div class="col-lg-auto">
<p class="number">
14
</p>
</div>
<div class="col-lg-auto">
<p class="number-text">Satisfied <br> Clients.</p>
</div>
</div>
</div>
you can use position: relative; and use top CSS property for moving down the text
I used a rem value for the top property, because if you px it not will be working for all devices.
.number-text {
/* here the trick */
position: relative;
top: 0.8rem;
}
I see also that you don't use the DRY method
DON'T REPEAT YOURSELF
do this instead
.experience,
.clients {
/* your CSS */
}
I also added the same colors you put in the image in reusable CSS variables
* {
--bg-color-blue: #252734;
--gold-orange: #e9b258;
}
that's it here the code
* {
--bg-color-blue: #252734;
--gold-orange: #e9b258;
}
body {
background-color: var(--bg-color-blue);
}
.experience,
.clients {
color: var(--gold-orange);
display: flex;
width: 50%;
align-items: center;
justify-content: center;
}
.number {
font-size: 5rem;
font-weight: bold;
}
.number-text {
float: right;
padding-left: 10px;
color: white;
/* here the trick */
position: relative;
top: 0.8rem;
}
.row {
display: flex;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="row">
<!-- first parent -->
<div class="experience">
<div class="col-lg-auto">
<p class="number">
12
</p>
</div>
<div class="col-lg-auto">
<p class="number-text">Years Of <br> Experience.</p>
</div>
</div>
<!-- second parent -->
<div class="clients">
<div class="col-lg-auto">
<p class="number">
14
</p>
</div>
<div class="col-lg-auto">
<p class="number-text">Satisfied <br> Clients.</p>
</div>
</div>
</div>
</body>
</html>
The following code should work. Just add the align-items:center; property to the .experience div.
.experience{
align-items:center;
}
You can use align-self: center on the container to be centred.
body {
font-family: sans-serif;
background: #000000;
}
#app {
display: flex;
}
.experience {
color: #fff;
display: flex;
width: 50%;
}
.number {
font-size: 5rem;
}
.number-text {
float: right;
padding-left: 10px;
}
.clients {
color: #fff;
display: flex;
width: 50%;
}
p {
margin: 0; // set margin to zero
// the p tag has a margin by default that you have to remove
}
.align-self-center {
align-self: center; make the container align itself to center
}
<div id="app">
<div class="experience">
<div class="col-lg-auto">
<p class="number">10</p>
</div>
<div class="col-lg-auto align-self-center">
<p class="number-text">
Years Of <br />
Experience.
</p>
</div>
</div>
<div class="clients">
<div class="col-lg-auto">
<p class="number">12</p>
</div>
<div class="col-lg-auto align-self-center">
<p class="number-text">
Satisfied <br />
Clients.
</p>
</div>
</div>
</div>

Is there a way to make each anchor/button not change/move its place upon resizing web-screen?

As you can see in the image provided, if i try to resize the webpage, the "read more" anchors/buttons are also moving. is there a way to make their respective places to remain unchanged upon resizing web-screen? i also tried position fixed.
This is the only code used with regards to the issue, i am using bootstrap with little css.
<section class="second-section">
<div class="container-fluid">
<div class="row text-center">
<div class="col-md bg-white border">
<div class="card-1 text-left ">
<h1>Business <span>Mentoring</span></h1>
<p>Our mentors are leading professional and experts in their field with a passion....</p>
Read more
</div>
</div>
<div class="col-md bg-white border">
<div class="card-2 text-left">
<h1>Business <span>Coaching</span></h1>
<p>Our coaches are successful professional and leaders in their field, who ....</p>
Read more
</div>
</div>
<div class="col-md bg-white border">
<div class="card-3 text-left">
<h1>Personal <span>Mentoring</span> and coaching</h1>
<p>is where have professionals ready to work with a family,...</p>
Read more
</div>
</div>
<div class="col-md bg-white border">
<div class="card-4 text-left">
<h1>Career <span>exploration</span></h1>
<p>Career advice and exploration is vital if you want to maximise your potential in today's....</p>
Read more
</div>
</div>
</div>
</div>
</section>
.card-1 .card-2 .card-3 .card-4 h1{
width: 100%;
font-size: 40px;
line-height: 50px;
font-family: "Montserrat Bold";
}
.card-1 h1 span{
display: block;
}
.card-1 .card-2 .card-3 .card-4 p{
width: 100%;
max-width: 325px;
font-size: 16px;
color: #232020;
line-height: 28px;;
font-family: "Montserrat Regular";
}
.second-section p{
margin: 0;
}
.readMore-anchor{
width: 100%;
height: 47px;
font-size: 16px;
max-width: 161px;
line-height: 50px;
padding: 15px 38px;
background-color: #8cd9f9; ;
}
Had this same issue awhile back and here is how I solved it (although there may be other ways):
Add position relative to the four container cards (note that this is not for the cards, it is for the buttons). In your example this would be the div which has the common class bg-white. Also add a padding to the bottom of the container cards that creates a space for the buttons to float in when we position them.
.bg-white {
position: relative;
padding-bottom: 60px;
}
Absolute position the buttons within the space we just created.
.bg-white > .text-left > .readMore-anchor {
position: absolute;
right: 10px;
bottom: 10px;
}
You should end up with something like this, where the white space between the text and the buttons will automatically adjust to match the card with the most text, keeping it uniform. (I didn't finish making mine quite as pretty as yours but I believe it has the functionality you are looking for).
.card-1 .card-2 .card-3 .card-4 h1{
width: 100%;
font-size: 40px;
line-height: 50px;
font-family: "Montserrat Bold";
}
.card-1 h1 span{
display: block;
}
.card-1 .card-2 .card-3 .card-4 p{
width: 100%;
max-width: 325px;
font-size: 16px;
color: #232020;
line-height: 28px;;
font-family: "Montserrat Regular";
}
.second-section p{
margin: 0;
}
.readMore-anchor{
width: 100%;
height: 47px;
font-size: 16px;
max-width: 161px;
line-height: 50px;
padding: 15px 38px;
background-color: #8cd9f9; ;
}
.bg-white {
position: relative;
padding-bottom: 60px;
}
.bg-white > .text-left > .readMore-anchor {
position: absolute;
right: 10px;
bottom: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<section class="second-section">
<div class="container-fluid">
<div class="row text-center">
<div class="col-md bg-white border">
<div class="card-1 text-left ">
<h1>Business <span>Mentoring</span></h1>
<p>Our mentors are leading professional and experts in their field with a passion....</p>
Read more
</div>
</div>
<div class="col-md bg-white border">
<div class="card-2 text-left">
<h1>Business <span>Coaching</span></h1>
<p>Our coaches are successful professional and leaders in their field, who ....</p>
Read more
</div>
</div>
<div class="col-md bg-white border">
<div class="card-3 text-left">
<h1>Personal <span>Mentoring</span> and coaching</h1>
<p>is where have professionals ready to work with a family,...</p>
Read more
</div>
</div>
<div class="col-md bg-white border">
<div class="card-4 text-left">
<h1>Career <span>exploration</span></h1>
<p>Career advice and exploration is vital if you want to maximise your potential in today's....</p>
Read more
</div>
</div>
</div>
</div>
</section>
add this to your existing css
.readMore-anchor{
position :absolute;
bottom:2%;//according to your need//
left:2%;//according to your need//
}
.container{
position :relative;
}
**wrap this anchor tag( with class readMore-anchor) around a div class container **

How to align elements and add icon to bootstrap li

I don't know how to center icon with the text. I have SVG + text. I can do it with plain CSS(flex-box) but I have to use bootstrap. Also, I want to center text, so it will be centered as other parts of the webpage, I want it to be aligned vertically
I have this:
I want to get this:
I have tried different solutions but did not come up with a good idea.
So the questions are:
How to make text to be centered to the left so it looks centered?
How to aligned svg icon with the text?
thanks
<section class="perks">
<img src="./media/blueCircle.svg" alt="" />
<div class="container">
<div class="row">
<div class="col perksFirst">Perks of Meetlete</div>
<div class="w-100"></div>
<div class="row perksList">
<div class="col">Access to our secure video platform!</div>
<div class="col">
<img src="./media/2.svg" alt="" />Calls are executed through our
App!
</div>
<div class="w-100"></div>
<div class="col">Metelete calls take place on your time!</div>
<div class="col">None of your information is shared!</div>
<div class="w-100"></div>
<div class="col">Build loyalty with your fans!</div>
<div class="col">Make lifetime memories!</div>
<div class="w-100"></div>
<div class="col">Earn up to 10x more than other platforms!</div>
<div class="col">Meetlete calls are timed!</div>
</div>
<div class="w-100"></div>
<div class="col">
<button class="earlyAccess btn">Early access</button>
<div class="launchDate">Launching 2/14/21!</div>
</div>
</div>
</section>
.perks {
display: flex;
text-align: center;
margin-top: 310px;
position: relative;
}
.perks .earlyAccess {
margin-top: 117px;
}
.perks img {
position: absolute;
left: 0;
top: -50%;
}
.perks .row {
justify-content: center;
}
.perksList {
max-width: 860px;
display: flex;
justify-content: center;
align-items: center;
}
.perksList .col {
font-weight: 600;
font-size: 18px;
display: flex;
align-items: center;
display: flex !important;
text-align: start;
margin-top: 26px;
}
.perksFirst {
margin-bottom: 77px;
font-size: 24px;
font-weight: 700;
}
.launchDate {
font-weight: 700;
font-size: 18px;
margin-top: 26px;
}
In order to align icons with the text you can put them together in a
Or you use bootstrap grid https://getbootstrap.com/docs/4.6/layout/grid/. You could use this easily to render it all dynamically, by putting your text in a list.
You can use text-align: center on the outer div (container) to center all. then text-align left in the inner one (perklist) in case this turns your text all left aligned.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
justify-content: center;
margin: auto;
text-align: left;
margin-top: 10px;
}
.heading {
text-align: center;
padding: .5rem;
}
.heading h3 {
font-size: 24px;
font-weight: 700;
text-transform: capitalize;
}
.card {
background: whitesmoke;
padding: 2rem;
border: darkgrey
}
span {
display: flex;
vertical-align: middle;
padding-top: 1rem;
}
span img {
display: inline-flex;
height: 2rem;
}
span a {
font-size: 18px;
font-weight: 600;
line-height: 2rem;
padding-left: .5rem;
}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solution By Tarak</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="new.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xl-1"></div>
<div class="card col-xl-10 col-sm-12">
<div class="row">
<div class="heading col-12">
<h3>Perks of Meetlete</h3>
</div>
</div>
<div class="row">
<div class="col-xl-6 col-md-12">
<span><img src="./test-tubes.svg" /><a>Access to our secure video platform!</a></span>
<span><img src="./test-tubes.svg" /><a>Metelete calls take place on your time!</a></span>
<span><img src="./test-tubes.svg" /><a>Build loyalty with your fans!</a></span>
<span><img src="./test-tubes.svg" /><a>Earn up to 10x more than other platforms!</a></span>
</div>
<div class="col-xl-6 col-md-12">
<span><img src="./test-tubes.svg" /><a>Calls are executed through our App!</a></span>
<span><img src="./test-tubes.svg" /><a>None of your information is shared!</a></span>
<span><img src="./test-tubes.svg" /><a>Make lifetime memories!</a></span>
<span><img src="./test-tubes.svg" /><a>Meetlete calls are timed!</a></span>
</div>
</div>
</div>
</div>
</div>
</body>
height of span img == line-height of span a (for it to be inline center)
change svg of your choice.
play with styles.

Same height title in bootstrap columns

I have html (bootstrap css) like this:
<div class="container">
<div class="row">
<div class="col-xs-6 col">
<div class="block">
<div class="title">
<strong>Dynamic title 1 line</strong>
</div>
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</div>
<div class="col-xs-6 col">
<div class="block">
<div class="title">
<strong>Dynamic title <br>more than 1 line</strong>
</div>
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</div>
</div>
</div>
And css like this
.block{
border: 1px solid black;
margin: 10px;
padding: 10px;
text-align: center;
}
.title{
margin-bottom: 10px;
min-height: 40px;
}
Title comes as dynamic text so it can be 1, 2, or 3 lines. Is there a way to make title height the same height as the height in the 'highest' title with css only. I want properties be aligned regardless of the title text coming in from api. I would like the above example to work without setting min-height: 40px; because I don't know what min-height should be.
http://jsfiddle.net/DTcHh/28125/
You can use the table.For solving this problem
.block{
margin: 10px;
padding: 10px;
text-align: center;
}
td.block-cell {
border: 1px solid #000;
}
.block-wrap {
background-color: transparent;
border-collapse: separate;
border-spacing: 10px;
}
.title{
margin-bottom: 10px;
min-height: 40px;
}
<!DOCTYPE html><head>
<title>Test</title><meta name='viewport' content='width=device-width,initial-scale=1.0,user-scalable=0'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<div class="container">
<table class="block-wrap">
<tr>
<td class="block-cell">
<div class="block">
<div class="title">
<strong>Dynamic title 1 line</strong>
</div>
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</td>
<td class="block-cell" >
<div class="block">
<div class="title">
<strong>Dynamic title <br>more than 1 line</strong>
</div>
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</td>
</tr>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>
As far as I am aware this is impossible in css only since the two elements are not siblings of each other. If that was the case display: table-cell could have been an option.
However there is a solution for this when using jQuery you can look up the highest .title element and set all the other .title elements to this heights.
See the following snippet:
var largest = 0;
//loop through all title elements
$(document).find(".title").each(function(){
var findHeight = $(this).height();
if(findHeight > largest){
largest = findHeight;
}
});
$(document).find(".title").css({"height":largest+"px"});
See the fiddle for an example: http://jsfiddle.net/DTcHh/28131/
You can override the CSS bootstrap, and to make the columns were of the same height using flexbox.
body {
margin: 10px;
}
.same-height-wrapp {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-wrap: wrap;
}
.same-height-wrapp > [class*='col-'] {
display: flex;
flex-direction: column;
}
.block{
border: 1px solid black;
margin: 10px;
padding: 10px;
text-align: center;
height: 100%;
position: relative;
}
.title{
margin-bottom: 60px;
}
.desc-wrapp{
position: absolute;
height: auto;
width: 100%;
bottom: 15px;
}
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row same-height-wrapp">
<div class="col-xs-6 col same-height">
<div class="block">
<div class="title">
<strong>Dynamic title 1 line</strong>
</div>
<div class="desc-wrapp">
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</div>
</div>
<div class="col-xs-6 col same-height">
<div class="block">
<div class="title">
<strong>Dynamic title <br>more than 1 line<br> line 2</strong>
</div>
<div class="desc-wrapp">
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</div>
</div>
</div>
</div>
With current HTML you can't make height of both blocks same with css.
However you can create a fake effect of having same height with :before or :after pseudo elements.
The trick is to use position: relative on .container and remove it from child .col-xs-* classes. Then use :before or :after pseudo element with wisely calculated left and width values.
.same-height-container {
position: relative;
}
.same-height-container .col {
position: static;
}
.same-height-container .col:before {
width: calc(50% - 30px - 20px); /* .container left-right padding +
.block left-right margin */
border: 1px solid black;
background: green;
position: absolute;
content: '';
left: 25px; /* container left padding + block left margin */
bottom: 10px;
top: 10px;
z-index: -1;
}
.same-height-container .col + .col:before {
right: 25px;
left: auto;
}
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
.block {
margin: 10px;
padding: 10px;
text-align: center;
}
.title{
margin-bottom: 10px;
min-height: 40px;
}
.same-height-container {
position: relative;
}
.same-height-container .col {
position: static;
}
.same-height-container .col:before {
width: calc(50% - 50px);
border: 1px solid black;
background: green;
position: absolute;
content: '';
left: 25px;
bottom: 10px;
top: 10px;
z-index: -1;
}
.same-height-container .col + .col:before {
right: 25px;
left: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container same-height-container">
<div class="row">
<div class="col-xs-6 col">
<div class="block">
<div class="title">
<strong>Dynamic title 1 line</strong>
</div>
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</div>
<div class="col-xs-6 col">
<div class="block">
<div class="title">
<strong>Dynamic title <br>more than 1 line Dynamic title <br>more than 1 lineDynamic title <br>more than 1 lineDynamic title <br>more than 1 line</strong>
</div>
<div>
<i>Prop 1</i>
</div>
<div>
Value 1
</div>
</div>
</div>
</div>
</div>
I adjust the solution a little bit:
function sameheight(div){
/* Latest compiled and minified JavaScript included as External Resource */
var largest = 160;
var findHeight = 0;
//loop through all title elements
$(document).find(div).each(function(){
findHeight = $(this).height();
if(findHeight > largest){
largest = findHeight;
}
});
$(document).find(div).css({"height":findHeight+"px"});
};
Then you can use the function with
sameheight(".blogtitle");