A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

How to create two div elements with same height side by side in CSS
Q:

How to create two div elements with same height side by side in CSS

0

How to create two div elements with same height side by side in CSS

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the CSS3 flexbox

With CSS3 flex layout model you can very easily create the equal height columns or <div> elements that are aligned side by side. Just apply the display property with the value flex on the container element and the flex property with the value 1 on child elements.

Let's try out the following example to understand how it basically works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Creating Two Equal Height Columns Using CSS</title>
<style>
.flex-container{
	width: 80%;
	min-height: 300px;
	margin: 0 auto;
	display: -webkit-flex; /* Safari */		
	display: flex; /* Standard syntax */
}
.flex-container .column{
	padding: 10px;
	background: #dbdfe5;
	-webkit-flex: 1; /* Safari */
	-ms-flex: 1; /* IE 10 */
	flex: 1; /* Standard syntax */
}
.flex-container .column.bg-alt{
	background: #b4bac0;
}
</style>
</head>
<body>
    <div class="flex-container">
        <div class="column">Column 1</div>
        <div class="column bg-alt">Column 2</div>
    </div>
</body>
</html>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now