Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a div the same height as its width in bootstrap

I'm trying to make a div height the same width as a col-md-3 in bootstrap so that as the page adjusts it keeps its "squareness". Outside of bootstrap I use vw, but that's not the case here and height 100%; doesn't work. Any ideas?? Needs to be simple and dynamic.

like image 855
jonwa Avatar asked Apr 17 '17 15:04

jonwa


2 Answers

It has been answered before from what I see.

div {
  background:orange;
  width:?%;
  padding-top:?%;
}

width = padding=top

See here css height same as width

like image 60
Vlad Pana Avatar answered Sep 29 '22 10:09

Vlad Pana


Bootstrap make same height as width. Width of the colum is added to padding so that you can get a squared box

.col-md-3{width:25%; padding:25%;}

https://jsfiddle.net/SHABU89/gee3mzsy/

like image 32
J. Shabu Avatar answered Sep 29 '22 11:09

J. Shabu