How to switch css table-cell from left to right? - html

I have 3 types of layout, I'm just having trouble with the third.
I used css based table for the 2nd layout with two columns because of its flexibility in terms of height. But I can't able to bring the left column to the right.
The html markup should be as is. Only selector is allowed.
Please help me play with it. thanks guys!
body {
margin: 10px auto;
width: 80%
}
.wrapper {
margin: 10px;
width: 100%;
}
ul.menu {
background: orange;
padding: 10px
}
.content {
background: #ddd;
padding: 10px
}
/* table layout */
.wrapper.table {
display: table;
table-layout: fixed;
}
.table ul.menu,
.table .content {
display: table-cell;
vertical-align: top;
float: none
}
.table ul.menu {
width: 180px;
}
h2 {
font-weight: bold
}
<h2>Original layout</h2>
<div class="wrapper">
<ul class="menu">
<li>menu</li>
</ul>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor labore et dolore magna Lorem ipsum dolor sit</div>
</div>
</div>
<h2>New layout after adding the selector "table"</h2>
<div class="wrapper table">
<ul class="menu">
<li>menu</li>
</ul>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor labore et dolore magna Lorem ipsum dolor sit</div>
</div>
</div>
<h2>Need help with this. (bring menu section to the right after adding the selector "right")</h2>
<div class="wrapper table">
<ul class="menu right">
<li>menu</li>
</ul>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor labore et dolore magna Lorem ipsum dolor sit</div>
</div>
</div>
jsFiddle: http://jsfiddle.net/g0x1o9bL/1/

rtl/ltr direction will do the trick :)
body { width:70%;margin:10px auto; }
.wrapper { width:100% }
.wrapper ul.menu { background:orange }
.wrapper .content { background:gray;}
.wrapper.table { display:table;table-layout:fixed;}
.wrapper.table ul.menu,
.wrapper.table .content { display: table-cell; direction: ltr;}
.wrapper.table ul.menu { width:180px; }
.wrapper.table.right { direction: rtl; }
<div class="wrapper">
<ul class="menu">
<li>menu</li>
</ul>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor labore et dolore magna Lorem ipsum dolor sit</div>
</div>
</div>
<br>
<div class="wrapper table">
<ul class="menu">
<li>menu</li>
</ul>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor labore et dolore magna Lorem ipsum dolor sit</div>
</div>
</div>
<br>
<div class="wrapper table right">
<ul class="menu">
<li>menu</li>
</ul>
<div class="content">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor labore et dolore magna Lorem ipsum dolor sit</div>
</div>
</div>

Like I said in comment section, if jQuery is allowed this is working solution (maybe not best one, not sure)
$(function(){
var elem = $("ul.right").parent("div.table");
var ul_right = $("ul.right").remove();
elem.append(ul_right);
})
http://jsfiddle.net/thisizmonster/g0x1o9bL/5/

Related

Bottom align image within auto height parent

I'm having two divs with the same height but different content. This content is dynamic made with a CMS. However I want to make the image and button to always be at the bottom of the div. How can I accomplish this? because I only get it to work if I use a fixed height, I never works with height: auto;
here is my HTML/CSS snippet
.box:nth-of-type(2n+1) {
margin-right: 10%;
}
.box {
width: 45%;
height: auto;
background-color: #ffffff;
box-shadow: 0 15px 14px -3px #d1daeb;
}
.box a {
font-size: 16px;
font-weight: 600;
letter-spacing: -0.2px;
color: #602b96;
padding: 15px 50px;
text-decoration: none;
}
.box a:hover {
color: #ffffff;
}
.box div {
padding: 35px 40px 0px 40px;
}
.box img {
padding-top: 35px;
width: 100%;
}
<div class="box">
<div>
<h2>Tittle of my div</h2>
<hr>
<span class="clearfix"></span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a class="buttonArticle" href="#">VIEW</a>
</div>
<img src="http://gbchope.com/wp-content/uploads/2016/10/events-placeholder.jpg" alt="" class="">
</div>
<div class="box">
<div>
<h2>Tittle of my div</h2>
<hr>
<span class="clearfix"></span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a class="buttonArticle" href="#">VIEW</a>
</div>
<img src="http://gbchope.com/wp-content/uploads/2016/10/events-placeholder.jpg" alt="" class="">
</div>
This is how it looks now:
How sould i do this?
You can do this by flex. These are the styles that I added
body {
margin:0;
display: flex;
}
.box {
display: flex;
flex-direction: column;
}
.box img {
margin-top: auto;
padding-top: 35px;
width: 100%;
}
body {
margin:0;
display: flex;
}
.box:nth-of-type(2n+1) {
margin-right: 10%;
}
.box {
display: flex;
flex-direction: column;
width: 45%;
height: auto;
background-color: #ffffff;
box-shadow: 0 15px 14px -3px #d1daeb;
}
.box a {
font-size: 16px;
font-weight: 600;
letter-spacing: -0.2px;
color: #602b96;
padding: 15px 50px;
text-decoration: none;
}
.box a:hover {
color: #ffffff;
}
.box div {
padding: 35px 40px 0px 40px;
}
.box img {
margin-top: auto;
padding-top: 35px;
width: 100%;
}
<div class="box">
<div>
<h2>Tittle of my div</h2>
<hr>
<span class="clearfix"></span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a class="buttonArticle" href="#">VIEW</a>
</div>
<img src="http://gbchope.com/wp-content/uploads/2016/10/events-placeholder.jpg" alt="" class="">
</div>
<div class="box">
<div>
<h2>Tittle of my div</h2>
<hr>
<span class="clearfix"></span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a class="buttonArticle" href="#">VIEW</a>
</div>
<img src="http://gbchope.com/wp-content/uploads/2016/10/events-placeholder.jpg" alt="" class="">
</div>
You can achieve this with flex and change some html
.box-wrapper {
display: flex;
align-items: stretch;
}
.box:nth-of-type(2n+1) {
margin-right: 10%;
}
.box {
width: 45%;
height: auto;
background-color: #ffffff;
box-shadow: 0 15px 14px -3px #d1daeb;
align-items: start;
display: flex;
flex-direction: column;
}
.box a {
font-size: 16px;
font-weight: 600;
letter-spacing: -0.2px;
color: #602b96;
padding: 15px 50px;
text-decoration: none;
}
.box a:hover {
color: #ffffff;
}
.box div {
padding: 35px 40px 0px 40px;
}
.box img {
padding-top: 35px;
width: 100%;
}
.mt-auto {
margin-top: auto;
}
.p-0 {
padding: 0 !important;
}
<div class="box-wrapper">
<div class="box">
<div>
<h2>Tittle of my div</h2>
<hr>
<span class="clearfix"></span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="mt-auto p-0">
<a class="buttonArticle" href="#">VIEW</a>
<img src="http://gbchope.com/wp-content/uploads/2016/10/events-placeholder.jpg" alt="" class="">
</div>
</div>
<div class="box">
<div>
<h2>Tittle of my div</h2>
<hr>
<span class="clearfix"></span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="mt-auto">
<a class="buttonArticle" href="#">VIEW</a>
<img src="http://gbchope.com/wp-content/uploads/2016/10/events-placeholder.jpg" alt="" class="">
</div>
</div>
</div>

How to make all buttons at equal distance from div

This is what I have presently -
.box{
background-color: #e61a39;
width: 25%;
float:left;
margin: 0px;
text-align: center;
min-height: 380px;
}
#container{
width: 90%;
margin: auto;
}
<section id="container">
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-1.png">
<h1>Our Menu</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolor</p>
<button>Discover Pizza</button>
</div>
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-3.png">
<h1>Your Nearest Store</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolor</p>
<button>Find Pizza Restaurants</button>
</div>
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/vector-smart-object.png">
<h1>Birthday Party</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolor</p>
<button>Book Now</button>
</div>
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/vector-smart-objectcopy-6.png">
<h1>Catering</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolor</p>
<button>Book Now</button>
</div>
</section>
This code makes my buttons uneven. What can I do so that all the buttons are at the same distance from the bottom of the box?
Use position css properties.
.box{
background-color: #e61a39;
width: 25%;
float:left;
margin: 0px;
text-align: center;
min-height: 380px;
position:relative;
}
button{
position:absolute;
bottom: 10px;
left:25%;
right:25%;
}
#container{
width: 90%;
margin: auto;
}
<section id="container">
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-1.png">
<h1>Our Menu</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolor</p>
<button>Discover Pizza</button>
</div>
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-3.png">
<h1>Your Nearest Store</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolor</p>
<button>Find Pizza Restaurants</button>
</div>
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/vector-smart-object.png">
<h1>Birthday Party</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolor</p>
<button>Book Now</button>
</div>
<div class="box">
<img src="https://www.dominos.co.in/theme2/front/images/home/vector-smart-objectcopy-6.png">
<h1>Catering</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolor</p>
<button>Book Now</button>
</div>
</section>
This is one way to do that
.box{
background-color: #e61a39;
text-align: center;
min-height: 380px;
display: flex;
flex-direction: column;
}
.box .content {
flex-grow: 1;
}
.box .button-wrapper {
height: 40px;
}
#container{
width: 90%;
display: flex;
justify-content: center;
}
<section id="container">
<div class="box">
<div class="content">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-1.png">
<h1>Our Menu</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolor</p>
</div>
<div class="button-wrapper">
<button>Discover Pizza</button>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-1.png">
<h1>Our Menu</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolor</p>
</div>
<div class="button-wrapper">
<button>Discover Pizza</button>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-1.png">
<h1>Our Menu</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolor</p>
</div>
<div class="button-wrapper">
<button>Discover Pizza</button>
</div>
</div>
<div class="box">
<div class="content">
<img src="https://www.dominos.co.in/theme2/front/images/home/layer-7-1.png">
<h1>Our Menu</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolor</p>
</div>
<div class="button-wrapper">
<button>Discover Pizza</button>
</div>
</div>
</section>
I used here flexbox (doesn't support ie10 and down).
This is a flexible way to do that because it's not absolute and doesn't depend on the height of the div above.
We define the height of button-wrapper and says to the 'content' div to have all of the rest of the 'box'.

How can I create a zoom in effect with background images using CSS?

I've got a flex setup of list items to display information. I have a background image attached to these list items but I would like to create a zoom in effect when hovered or focused by a mouse. I think i'm partly on the way there, however my current setup makes it so that they are stretched out on mobile screens. I'm wondering if there's a way to achieve what i'm trying to do that is responsive.
I've searched for similar posts and I find that a lot of people use overflow: hidden; with a transform scale, I can't seem to get that to work with flex. Any help would be greatly appreciated!
body {
font-family: sans-serif;
}
h2 {
color: #3CAD5D;
padding-bottom: 0px;
margin-bottom: 0px;
}
ul {
margin: 0 auto;
padding: 0;
list-style: none;
display: flex;
flex-direction: row;
flex-wrap: wrap;
max-width: 1500px;
width: 100%;
}
li {
display: flex;
width: calc(33.333333% - 10px);
}
a {
flex-grow: 1;
box-sizing: border-box;
text-decoration: none;
color: #000;
box-shadow: 3px 3px 5px #888888;
padding: 20px;
}
a:hover {
color: #fff;
}
/*** MEDIA QUERIES ***/
#media screen and (max-width: 800px) {
ul {
flex-direction: column;
/* change direction of flex for mobile */
margin: 0 auto;
}
li {
width: 97%;
}
}
/*** BG WITH ZOOM ***/
.bg1 {
background: url('https://cmeimg-a.akamaihd.net/640/clsd/getty/c64f76dc20c246ca88ee180fe4b4b781');
margin: 5px;
}
.bg2 {
background: url('http://www.petmd.com/sites/default/files/hypoallergenic-cat-breeds.jpg');
margin: 5px;
}
.bg3 {
background: url('https://ichef.bbci.co.uk/images/ic/560x315/p0517py6.jpg');
margin: 5px;
}
.bg1,
.bg2,
.bg3 {
background-size: 100% 100%;
background-repeat: no-repeat;
-webkit-transition: all .5s;
-moz-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
}
.bg1:hover,
.bg2:hover,
.bg3:hover {
background-size: 130% 130%;
}
<ul>
<li class="bg1">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg2">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg3">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg1">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg2">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg3">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
</ul>
Update
For the first 3 images:
Added a <div> to each <li> then removed .bg* .classes from the <li> and gave them to the new inner <div>. Then added overflow:hidden to <li>.
Added transform: scale(1.3) to the *:hover rulesets.
Changed background-size:100% 100% to background-size:cover
Demo
body {
font-family: sans-serif;
}
h2 {
color: #3CAD5D;
padding-bottom: 0px;
margin-bottom: 0px;
}
ul {
margin: 0 auto;
padding: 0;
list-style: none;
display: flex;
flex-direction: row;
flex-wrap: wrap;
max-width: 1500px;
width: 100%;
}
li {
display: flex;
width: calc(33.333333% - 10px);
overflow: hidden;
}
a {
flex-grow: 1;
box-sizing: border-box;
text-decoration: none;
color: #000;
box-shadow: 3px 3px 5px #888888;
padding: 20px;
}
a:hover {
color: #fff;
}
/*** MEDIA QUERIES ***/
#media screen and (max-width: 800px) {
ul {
flex-direction: column;
/* change direction of flex for mobile */
margin: 0 auto;
}
li {
width: 97%;
}
}
/*** BG WITH ZOOM ***/
.bg1 {
background: url('https://cmeimg-a.akamaihd.net/640/clsd/getty/c64f76dc20c246ca88ee180fe4b4b781');
margin: 5px;
}
.bg2 {
background: url('http://www.petmd.com/sites/default/files/hypoallergenic-cat-breeds.jpg');
margin: 5px;
}
.bg3 {
background: url('https://ichef.bbci.co.uk/images/ic/560x315/p0517py6.jpg');
margin: 5px;
}
.bg1,
.bg2,
.bg3 {
background-size: cover;
/* Changed to cover */
background-repeat: no-repeat;
-webkit-transition: all .5s;
-moz-transition: all .5s;
-o-transition: all .5s;
transition: all .5s;
}
.bg1:hover,
.bg2:hover,
.bg3:hover {
transform: scale(1.3);
/* Changed to transform:scale() */
}
<ul>
<li>
<div class="bg1">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</div>
</li>
<li>
<div class="bg2">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</div>
</li>
<li>
<div class="bg3">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</div>
</li>
<li class="bg1">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg2">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
<li class="bg3">
<a href="#">
<h2>References</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</a>
</li>
</ul>

Triangle on a div bottom

I have a problem with taking a triangle on a bottom of div, as you can see in image below. This three div's are in flexbox.
HTML code:
<section class="main_content">
<div class="1st_class">
<div class="features">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</p>
<div class="triangle"></div>
</div>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
If you want a flexible solution I would recommend using an SVG background image of a triangle and then stretching it across the bottom of the box.
I have created a jsFiddle to show what I mean.
.active:after {
content: '';
position: absolute;
bottom: -15px;
left: 0;
width: 100%;
height: 15px;
background-size: 100% 100%;
background-image: url(triangle.svg);
}

Inline-block elements of the same height in a few lines

Can I do all the blocks of the same height without JS and min-height (as a special case)? Blocks can be placed on multiple lines.
Example jsfiddle
ul {
font-size: 0;
max-width: 300px;
text-align: center;
}
li {
vertical-align: top;
display: inline-block;
width: 30%;
margin: 1%;
background: grey;
font-size: 12px;
}
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
</ul>
If flexbox is an option, then you can make ul a wrapping flexbox.
How this works?
display: flex creates a flexbox which has the property to distribute whitespace between its children in various ways.
flex-wrap: wrap allows the lis to go to the next line depending on the content
justify-content: center does horizontal centering.
Vertically the lis have a property called align-items: stretch, which is the default - this allows the heights of the lis to be equal in a line.
See demo below:
ul {
font-size: 0;
max-width: 300px;
text-align: center;
display:flex;
flex-wrap:wrap;
justify-content:center;
}
li {
vertical-align: top;
display: inline-block;
width: 30%;
margin: 1%;
background: grey;
font-size: 12px;
}
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
</ul>
Easily, using display: flex.
Specify the orientation + wrapping in flex-flow: row wrap; and the central alignment in justify-content: center;
Example:
ul {
display: flex;
flex-flow: row wrap;
justify-content: center;
font-size: 0;
max-width: 300px;
text-align: center;
}
li {
vertical-align: top;
display: inline-block;
width: 30%;
margin: 1%;
background: grey;
font-size: 12px;
}
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
</ul>