0

I am attempting to add a class to either vertically align top, middle or bottom, but I am obviously missing something:

.row {	display: flex; background-color: #f0f0f0; } .col-3 {	-ms-flex-preferred-size: 25%;	flex-basis: 25%;	max-width: 25%; } [class*='col-'].col-top {	align-items: flex-start; } [class*='col-'].col-center {	align-items: center; } [class*='col-'].col-bottom {	align-items: flex-end; }
<div class="row"> <div class="col-3"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <div class="col-3 col-center"> middle </div> <div class="col-3 col-bottom"> right </div> </div>

1 Answer 1

3

Your columns need to have display: flex as well :)

.row {	display: flex; background-color: #f0f0f0; } .col-3 {	-ms-flex-preferred-size: 25%;	flex-basis: 25%;	max-width: 25%; display: flex; } [class*='col-'].col-top {	align-items: flex-start; } [class*='col-'].col-center {	align-items: center; background: #ff9000; } [class*='col-'].col-bottom {	align-items: flex-end; background: #0099ff; }
<div class="row"> <div class="col-3"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <div class="col-3 col-center"> middle </div> <div class="col-3 col-bottom"> right </div> </div>

Sign up to request clarification or add additional context in comments.

2 Comments

Of course, thank you. I can't believe I overlooked that.
:) when you look at something too long its always the simplest thing.. haha

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.