CSS resposive divs inside container

I have a div that acts as a container.
.cont {
width:100%;
min-height:200px;
}
I have 10 boxes that will be inside of that container.  so each box has a width of 20% so I can have two rows of 5.
.container-box {
width:20%;
float:left;
}
what do I add to the css to keep each of those boxes proportionate in height so they remain square? And so the text remains centered both vertically and horizontally?
LVL 7
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
check this example fiddle
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
Not a pure css solution - uses some javascript but is responsive
<!doctype html>
<html>
<head>
<title>Test</title>
<style type="text/css">
* {
	padding: 0;
	margin: 0;
	box-sizing: border-box;
}
.container {
	width: 100%;
}
.row {
	padding: 0;
	margin-left: -15px;
	margin-right: -15px;
}
.row:after {
	content: " ";
	float: none;
}
.col-lg-1 {
	padding-left: 15px;
	padding-right: 15px;
	float: left;
	width: 20%;
	color: #fff;
	background: #ae883f;
	text-align: center;
}
.col-lg-1.b {
	background: #e883fa;
}
.col-lg-1.c {
	background: #883fae;
}
.col-lg-1.d {
	background: #83fae8;
}
.col-lg-1.e {
	background: #3fae88;
}
</style>

</head>
<body>
<div class="container">
	<div class="row">
		<div class="col-lg-1 a">One</div>
		<div class="col-lg-1 b">Two</div>
		<div class="col-lg-1 c">Three</div>
		<div class="col-lg-1 d">Four</div>
		<div class="col-lg-1 e">Five</div>
	</div>
	<div class="row">
		<div class="col-lg-1 c">One</div>
		<div class="col-lg-1 d">Two</div>
		<div class="col-lg-1 e">Three</div>
		<div class="col-lg-1 b">Four</div>
		<div class="col-lg-1 a">Five</div>
	</div>
</div>
<script src="http://code.jquery.com/jquery.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script type="text/javascript">
$(function() {
	setHeight();
	$(window).resize(function() {
		setHeight();
	});
});
function setHeight()
{
	var width = $('.col-lg-1').width();
	$('.col-lg-1').height(width).css({lineHeight: width + 'px'});
}
</script>
</body>
</html>

Open in new window

Sample here http://www.marcorpsa.com/ee/t807.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.