CSS

How to Place Two DIVs with Same Height Side by Side in CSS

With CSS3, you can very easily create columns or <div> elements of the same height aligned side by side. Just apply display property with flex value on the parent element and the flex property with the value = 1 on the sub-elements, as shown in the example below:
 

CSS
.row {
    display: flex;
}

.col {
    flex: 1; 
    padding: 1em;
    border: solid;
}
 

HTML
<!DOCTYPE html>
<html>
	<head>
		<style>
		    /* Put the CSS Style Here */
		</style>
	</head>
	<body>
		<div class="row">
		  <div class="col">Morbi nisl justo, viverra ut tempor sit amet, malesuada ac neque. Proin est elit, tempor ut auctor quis, maximus in erat.</div>
		  <div class="col">Fusce ut aliquet sapien. Phasellus vel nibh eu lacus molestie sodales. Phasellus a mauris pellentesque, interdum risus et, pretium magna. Phasellus eget justo faucibus, tempor risus eu, iaculis mi. Quisque scelerisque imperdiet mauris a luctus. Integer lacinia, augue sed finibus mattis, tortor ligula imperdiet turpis, vel efficitur arcu est a nibh.</div>
		</div>
	</body>
</html>
Result
Morbi nisl justo, viverra ut tempor sit amet, malesuada ac neque. Proin est elit, tempor ut auctor quis, maximus in erat.
Fusce ut aliquet sapien. Phasellus vel nibh eu lacus molestie sodales. Phasellus a mauris pellentesque, interdum risus et, pretium magna. Phasellus eget justo faucibus, tempor risus eu, iaculis mi. Quisque scelerisque imperdiet mauris a luctus. Integer lacinia, augue sed finibus mattis, tortor ligula imperdiet turpis, vel efficitur arcu est a nibh.
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *