Getting 2 classes next to each other - html

I am trying to get 2 classes that are under each other to get next to each other.
Here is a screenshot of the 2 classes:
The right class is .testm_boxes1. The left class is .testm_boxes2
Here is the HTML and CSS:
.testm_boxes1 {
text-align: center;
float: right !important;
}
.testm_boxes2 {
text-align: center;
float: left !important;
}
<div class="wpb_wrapper">
<h3 style="font-size: 30px;text-align: center;font-family:Roboto;font-weight:700;font-style:normal" class="vc_custom_heading vc_custom_1509530836762">Wat zeggen anderen?</h3>
<div class="vc_row wpb_row vc_inner vc_row-fluid">
<div class="testm_boxes1 wpb_column vc_column_container vc_col-sm-6">
<div class="vc_column-inner ">
<div class="wpb_wrapper">
<div class="ult-just-icon-wrapper ">
<div class="align-icon" style="text-align:center;">
<div class="aio-icon circle " style="color:#383785;background:#51b6ea;font-size:20px;display:inline-block;">
<i class="Defaults-quote-left"></i>
</div>
</div>
</div>
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div id="Content">
<div class="boxed">
<div id="lipsum">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br> Phasellus sapien orci, varius vel accumsan ac,<br> varius eu nisl. Ut in mauris elementum, facilisis ex ac, tincidunt erat.</p>
<blockquote>
<p>
<em>-John Doe</em>
</p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="vc_row wpb_row vc_inner vc_row-fluid">
<div class="testm_boxes2 wpb_column vc_column_container vc_col-sm-6">
<div class="vc_column-inner ">
<div class="wpb_wrapper">
<div class="ult-just-icon-wrapper ">
<div class="align-icon" style="text-align:center;">
<div class="aio-icon circle " style="color:#383785;background:#51b6ea;font-size:20px;display:inline-block;">
<i class="Defaults-quote-left"></i>
</div>
</div>
</div>
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div id="Content">
<div class="boxed">
<div id="lipsum">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br> Phasellus sapien orci, varius vel accumsan ac,<br> varius eu nisl. Ut in mauris elementum, facilisis ex ac, tincidunt erat.</p>
<blockquote>
<p>
<em>-John Doe</em>
</p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

You have a container .vc_row around each of your testm boxes.
<div class="wpb_wrapper">
<div class="vc_row other_classes">
<div class="testm_boxes1 other_classes">
content
</div>
</div>
<div class="vc_row other_classes">
<div class="testm_boxes2 other_classes">
content
</div>
</div>
</div>
You need to move the .testm_boxesX class to the .vc_row container.
<div class="wpb_wrapper">
<div class="vc_row testm_boxes1 other_classes">
<div class="other_classes">
content
</div>
</div>
<div class="vc_row testm_boxes2 other_classes">
<div class="other_classes">
content
</div>
</div>
</div>
This way the two containers can sit next to each other.
The CSS float:left and float:right will push the content to either side, but you must set a width to the floated items.
Set width: 50%; to both .testm_boxes1 and .testm_boxes2 in your CSS.
See jsfiddle with these changes applied to your code:
http://jsfiddle.net/r7yk8ao8/

You can place the two elements next to each other by adding one style setting that limits each elements' max width to less than half the width of the screen, like so:
max-width: 49%;
Here is a working example:
.testm_boxes1 {
text-align: center;
float: right !important;
max-width: 49%;
}
.testm_boxes2 {
text-align: center;
float: left !important;
max-width: 49%;
}
<div class="wpb_wrapper">
<h3 style="font-size: 30px;text-align: center;font-family:Roboto;font-weight:700;font-style:normal" class="vc_custom_heading vc_custom_1509530836762">Wat zeggen anderen?</h3>
<div class="vc_row wpb_row vc_inner vc_row-fluid">
<div class="testm_boxes1 wpb_column vc_column_container vc_col-sm-6">
<div class="vc_column-inner ">
<div class="wpb_wrapper">
<div class="ult-just-icon-wrapper ">
<div class="align-icon" style="text-align:center;">
<div class="aio-icon circle " style="color:#383785;background:#51b6ea;font-size:20px;display:inline-block;">
<i class="Defaults-quote-left"></i>
</div>
</div>
</div>
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div id="Content">
<div class="boxed">
<div id="lipsum">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br> Phasellus sapien orci, varius vel accumsan ac,<br> varius eu nisl. Ut in mauris elementum, facilisis ex ac, tincidunt erat.</p>
<blockquote>
<p>
<em>-John Doe</em>
</p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="vc_row wpb_row vc_inner vc_row-fluid">
<div class="testm_boxes2 wpb_column vc_column_container vc_col-sm-6">
<div class="vc_column-inner ">
<div class="wpb_wrapper">
<div class="ult-just-icon-wrapper ">
<div class="align-icon" style="text-align:center;">
<div class="aio-icon circle " style="color:#383785;background:#51b6ea;font-size:20px;display:inline-block;">
<i class="Defaults-quote-left"></i>
</div>
</div>
</div>
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div id="Content">
<div class="boxed">
<div id="lipsum">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br> Phasellus sapien orci, varius vel accumsan ac,<br> varius eu nisl. Ut in mauris elementum, facilisis ex ac, tincidunt erat.</p>
<blockquote>
<p>
<em>-John Doe</em>
</p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Related

HTML & CSS: Bootstrap columns

I'm trying to create a grid system but I can't figure how to put the columns. To be more clear, I want the horizontal cards to be one under another without being divided. I tried changing the orded of the blocks but didn't seem to work at all. I'm using Bootstrap 4.
<div class="row">
<div class="col-lg-8 col-md-12">
<div class="card">
<div class="card-header card-header-text card-header-warning">
<div class="card-text">
Welcome back, <b><?php echo $display_name; ?></b>!
</div>
</div>
<div class="card-body">
<h4 class="card-title">Info</h4>
<p class="card-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras odio dui, sodales vitae fringilla quis, porta in nunc..
</p>
<footer class="blockquote-footer">Lorem</footer>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-header card-header-text card-header-danger">
<div class="card-text">
<h4 class="card-title">News</h4>
</div>
</div>
<?php
while($row = $stmtNews->fetch(PDO::FETCH_ASSOC)){
$row['date'] = date('j M', strtotime($row['date']));
?>
<div class="card-body" style="max-height: 80px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
<?php echo $row['news']; ?>
<div class="card-footer">
<div class="card-text">
<small class="text-time"><?php echo $row['date']; ?></em></small>
</div>
</div>
</div>
<div class="dropdown-divider" style="margin: 15px;"></div>
<?php
}
?>
</div>
</div>
<div class="col-lg-8 col-md-12">
<div class="card">
<div class="card-header card-header-text card-header-warning">
<div class="card-text">
Welcome back, <b><?php echo $display_name; ?></b>!
</div>
</div>
<div class="card-body">
<h4 class="card-title">Info</h4>
<p class="card-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras odio dui, sodales vitae fringilla quis, porta in nunc...
</p>
<footer class="blockquote-footer">Lorem</footer>
</div>
</div>
</div>
</div>
I don't know exactly what you want to achieve, but maybe this approach could help you:
<div class="row">
<div class="col-sm-9">
Level 1: .col-sm-9
<div class="row">
<div class="col-sm-12">
Level 2: .col-12
</div>
<div class="col-sm-12">
Level 2: .col-12
</div>
</div>
</div>
<div class="col-sm-2">
Level 1: .col-sm-2
<div class="row">
<div class="col-sm-12">
Level 2: .col-12 with defined or dynamic height
</div>
</div>
</div>
</div>
It results in this grid:
It may not be the best idea, but it may be a first approach to solve your problem.

How to create a side scroller with two rows of elements instead of one row?

I am trying to create a side scroller with 2 boxes per visible at a time using flex (One on top and one underneath)
As you can see on the first bunch of boxes below, I have it successfully horizontally scrolling, but I want there to be two rows of boxes in view instead of one row.
.box-flex-row {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
overflow-x: auto;
}
.box-flex-row > .m4 {
min-width: 45%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet"/>
<div class="container">
<div class="section">
<div class="row box-flex-row">
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
</div>
</div>
<hr>
<div class="section">
<div class="row">
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
</div>
</div>
<hr class="hr-bottom-line">
<div class="section">
<div class="row">
<h2>Stuff</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent auctor, nibh sit amet ultrices gravida, tortor magna pretium nunc, at ultricies ipsum libero ac mi. Sed a dictum turpis. Integer vitae ante sed neque ultrices congue. Sed euismod
nunc id magna aliquet dictum id id erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum porta mauris ut sapien molestie lacinia. Sed ullamcorper purus a lorem porta, et imperdiet mauris imperdiet.
Nullam sit amet neque nibh. Pellentesque non magna sed diam tincidunt accumsan quis quis magna. Vivamus urna turpis, ornare id malesuada vel, fringilla eget elit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Suspendisse posuere mi eget augue scelerisque euismod. Phasellus quis aliquam dolor, et dapibus urna. Proin suscipit et ligula at semper. Ut tristique magna vitae finibus pellentesque. Phasellus tincidunt tortor et sem posuere, et feugiat
tellus lacinia. Praesent commodo ullamcorper eros quis suscipit. Nam sed justo tortor. Nulla facilisi. Pellentesque ut lacus sit amet lacus mattis aliquet. Morbi eu purus elit. Aenean rhoncus, lectus vitae aliquet fringilla, eros metus fermentum
metus, vel malesuada arcu turpis non dolor. Curabitur non ex sed est vehicula efficitur. Fusce vel enim in lectus viverra luctus. Fusce ac sapien porttitor, consectetur massa ut, suscipit nulla. Fusce nec massa lobortis, tincidunt ex eget, ultrices
felis. Vivamus turpis justo, varius vel tincidunt sed, consequat a purus. Aliquam ultrices eros fermentum nunc dignissim, quis maximus eros malesuada. Vivamus non porttitor quam, id efficitur libero. Donec vulputate posuere viverra. Fusce iaculis
tellus sit amet orci consequat, at sagittis magna rhoncus. Maecenas ac dapibus est, vel auctor lectus. Integer porta lacus dui, eu scelerisque enim iaculis id. Aliquam eget pulvinar nisl. In hac habitasse platea dictumst. Curabitur et rutrum sem.
Cras viverra pharetra est. Etiam at molestie ipsum. Donec varius pulvinar tortor, in semper lacus. Nunc vel luctus dui. In eu neque et erat eleifend sodales. Pellentesque id ligula sed risus tempor maximus. Quisque turpis felis, condimentum et
bibendum ac, congue eu arcu. Aenean rutrum ante et dui pharetra, sed mattis risus accumsan. Mauris vulputate venenatis urna, at venenatis purus. In vitae pellentesque arcu. Maecenas fringilla arcu sed dolor sollicitudin, ut aliquet nisi auctor.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam dictum lacus et ornare mollis. Suspendisse potenti. Donec eu leo porttitor, ullamcorper arcu at, sagittis augue. Praesent ante urna, pellentesque
sed interdum in, malesuada sit amet turpis. Mauris imperdiet et ipsum at hendrerit. Nunc facilisis quam eu rutrum cursus. Quisque convallis ante eu ultrices varius. Cras et sapien odio. Morbi quis dui vitae tellus mattis eleifend. Vestibulum posuere
sapien elit, nec pretium metus pulvinar nec. Aliquam bibendum magna sit amet urna blandit lobortis.</p>
</div>
</div>
<br><br>
</div>
I have also created a CodePen example. Here's a image of how it looks and how I'd like it to look:
Update:
Out of the answers below, I was able to create the exact solution I needed: CodePen example
You have one flex container with a row of items and horizontal scroll.
You want two rows and horizontal scroll.
So put the two rows in a larger flex container with flex-direction: column.
Give the nested row containers full width.
Add the scroll function to the larger container.
revised codepen
.section {
display: flex;
flex-direction: column;
overflow: auto;
}
.box-flex-row {
width: 100%;
display: flex;
flex-wrap: nowrap;
}
.box-flex-row > .m4 {
min-width: 45%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet"/>
<div class="container">
<div class="section">
<div class="row box-flex-row">
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
</div>
<div class="row box-flex-row">
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
<div class="col s12 m4">
<a href="#" style="display: block;">
<div class="card">
<div class="card-content">
<h3 class="black-text">Test</h3>
</div>
<div class="card-action" style="border-bottom: 2px solid #1e39ef">
<p class="blue-grey-text">Lower test</p>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
Since you want two independent rows on mobile screens, and the cards to merge together (as in one container) on larger screens, flexbox may not be the best solution.
CSS Grid may not be the best solution either – you may need JavaScript – but here's a grid concept that you may find useful:
codepen demo
.box-flex-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 45%));
grid-auto-rows: 100px;
grid-gap: 10px;
overflow: auto;
padding: 10px;
background-color: lightgray;
}
#media (max-width: 601px) {
.m4:nth-child(-n + 6) {
grid-row: 1;
}
.m4:nth-child(n + 6) {
grid-row: 2;
}
.box-flex-row {
grid-template-columns: none;
grid-auto-columns: 45%;
}
}
.m4 {
border: 1px solid gray;
background-color: lightgreen;
font-size: 1.2em;
display: flex;
align-items: center;
justify-content: center;
}
.m4:nth-child(-n + 6) {
background-color: lightgreen;
}
.m4:nth-child(n + 6) {
background-color: orange;
}
body {
margin: 0;
}
<div class="container">
<div class="section">
<div class="row box-flex-row">
<div class="col s12 m4">test 1 upper</div>
<div class="col s12 m4">test 2 upper</div>
<div class="col s12 m4">test 3 upper</div>
<div class="col s12 m4">test 4 upper</div>
<div class="col s12 m4">test 5 upper</div>
<div class="col s12 m4">test 1 lower</div>
<div class="col s12 m4">test 2 lower</div>
<div class="col s12 m4">test 3 lower</div>
<div class="col s12 m4">test 4 lower</div>
<div class="col s12 m4">test 5 lower</div>
<div class="col s12 m4">test 6 lower</div>
</div>
</div>
</div>
I messed around with it and I think I found a solution.
By setting flex: column and height of content to 50%, it'll create two infinite rows.
When you want it to display regularly for desktop, set flex: row and set the width of content to 30% with flex: 0 0 30%. Not sure if it's the best way to do it but it's the only way I found that worked.
.scroll-container{
width: 70%;
margin: 0 auto;
height: 250px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: flex-start;
overflow-x: scroll;
}
.scroll-content{
height: 125px;
width: 100px;
background-color:rgb(77, 162, 241);
flex: 0 0 50%;
margin: 0;
padding: 0;
float: left;
border-right: 1px solid grey;
}
.scroll-content:nth-child(2n+1){
background-color: rgb(43, 156, 43);
}
#media only screen and (min-width: 700px){
.scroll-container{
overflow-x: unset;
flex-direction: row;
width: 700px;
justify-content: space-between;
}
.scroll-content{
width: 10px;
flex: 0 0 30%;
margin-top: 20px;
}
}
<div class='scroll-container'>
<div class='scroll-content'>Content 1</div>
<div class='scroll-content'>Content 2</div>
<div class='scroll-content'>Content 3</div>
<div class='scroll-content'>Content 4</div>
<div class='scroll-content'>Content 5</div>
<div class='scroll-content'>Content 6</div>
<div class='scroll-content'>Content 7</div>
<div class='scroll-content'>Content 8</div>
<div class='scroll-content'>Content 9</div>
<div class='scroll-content'>Content 10</div>
<div class='scroll-content'>Content 11</div>
<div class='scroll-content'>Content 12</div>
<div class='scroll-content'>Content 13</div>
<div class='scroll-content'>Content 14</div>
<div class='scroll-content'>Content 15</div>
<div class='scroll-content'>Content 16</div>
<div class='scroll-content'>Content 17</div>
<div class='scroll-content'>Content 18</div>
<div class='scroll-content'>Content 19</div>
<div class='scroll-content'>Content 20</div>
<div class='scroll-content'>Content 21</div>
<div class='scroll-content'>Content 22</div>
<div class='scroll-content'>Content 23</div>
<div class='scroll-content'>Content 24</div>
<div class='scroll-content'>Content 25</div>
<div class='scroll-content'>Content 26</div>
<div class='scroll-content'>Content 27</div>
<div class='scroll-content'>Content 28</div>
<div class='scroll-content'>Content 29</div>
<div class='scroll-content'>Content 30</div>
<div class='scroll-content'>Content 31</div>
<div class='scroll-content'>Content 32</div>
<div class='scroll-content'>Content 33</div>
</div>
CodePen Example

How to align images across different divs horizontally

Can you please help me understand how to align images horizontally across different divs in the same row regardless of the inner content of the div?
I've tried absolute positioning, but I'm required for this interview test to keep everything within the inner div container.
Example:
<div class="row">
<div class="col-md-3 product-box">
<div class="col-md-12 background-contain">
<p class="blue-title">Product Title 1</p>
Staring at $500
<br> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br>
<div class="img-contain">
<img src="materials/images/cereal_b.jpg" class="img-responsive" alt="cereal" />
</div>
<a class="bottom-link">Learn More</a>
</div>
</div>
<div class="col-md-3 product-box">
<div class="col-md-12 background-contain">
<p class="blue-title">Product Title 2</p>
Staring at 1900
<br> Donec ornare magna sit amet erat molestie sollicitudin ac vitae lectus.</br>
<img src="materials/images/flower_b.jpg" class="img-responsive" alt="cereal" />
<a class="bottom-link">Learn More</a>
</div>
</div>
<div class="col-md-3 product-box">
<div class="col-md-12 background-contain">
<p class="blue-title">Product Title 3</p>
Staring at 1900
<br> Cras non metus sed odio tristique imperdiet.</br>
<img src="materials/images/machine_b.jpg" class="img-responsive" alt="cereal" />
<a class="bottom-link">Learn More</a>
</div>
</div>
<div class="col-md-3 product-box">
<div class="col-md-12 background-contain">
<p class="blue-title">Product Title 4</p>
Staring at 1900
<br> Pellentesque mattis tellus ut molestie dapibus.</br>
<img src="materials/images/candy_b.jpg" class="img-responsive" alt="cereal" />
<a class="bottom-link">Learn More</a>
</div>
</div>
</div>
</div>
Try to use Bootstrap class -"container-fluid".
Here is jsfiddle: https://jsfiddle.net/z5v6t048/
<div class="container-fluid">
<div class="row">
<div class="col-sm-6 product-box">
<div class="col-md-12 background-contain">
<p class="blue-title">Product Title 1</p>
Staring at $500
<br> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br>
<div class="img-contain">
<img src="materials/images/cereal_b.jpg" class="img-responsive" alt="cereal" />
</div>
<a class="bottom-link">Learn More</a>
</div>
</div>
<div class="col-sm-6 product-box">
<div class="col-md-12 background-contain">
<p class="blue-title">Product Title 2</p>
Staring at 1900
<br/> Donec ornare magna sit amet erat molestie sollicitudin ac vitae lectus.
<img src="materials/images/flower_b.jpg" class="img-responsive" alt="cereal" />
<a class="bottom-link">Learn More</a>
</div>
</div>
</div>

Card resize Materialize

I'm trying to use 3 card to display the latest news on the site. On wide screen it looks fine like this
however when I resize the page to the content overflow from the card
this the the code snipplet
<div class="row">
<div class="col s4">
<div class="card small">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">flash_on</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[2]->title; ?></h5>
<p class="light"><?php custom_echo($children[2]->body, 200); ?></p>
</div> </div>
</div>
</div>
<div class="col s4">
<div class="card small">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">group</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[1]->title; ?></h5>
<p class="light"><?php custom_echo($children[1]->body, 200); ?></p>
</div> </div>
</div>
</div>
<div class="col s4">
<div class="card small">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">settings</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[0]->title; ?></h5>
<p class="light"><?php custom_echo($children[0]->body, 200); ?></p>
</div> </div>
</div>
</div>
</div>
</div>
</div>
</div>
It is because you have the class small added to your cards. Remove that class and the cards will resize with your content. When working with Materialize cards, the classes small, medium and large all limit the height of the card, no matter the content.
Also, to get a more responsive look, you should think about changing your col classes up to look something like this, and add a container div, which helps you center and contain your content:
<div class="container">
<div class="row">
<div class="col s12 m4">
<div class="card">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">flash_on</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[2]->title; ?></h5>
<p class="light"><?php custom_echo($children[2]->body, 200); ?></p>
</div>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">group</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[1]->title; ?></h5>
<p class="light"><?php custom_echo($children[1]->body, 200); ?></p>
</div>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons">settings</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[0]->title; ?></h5>
<p class="light"><?php custom_echo($children[0]->body, 200); ?></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Try putting the .icon-block div inside a .card-content. If the problem still persists try getting rid of the .icon-block class just to see how the cards react without it.
Using a div with the class .card-content will give your card padding of 20px evenly around the all the content inside, and an overlflow:hidden. This should give structure to your card.
<div class="row">
<div class="col s4">
<div class="card ">
<!-- card-content- gives padding and overflow hidden to the content inside -->
<div class="card-content">
<div class="icon-block">
<h2 class="center brown-text"><i class="material-icons medium">flash_on</i></h2>
<div class="card-content">
<h5 class="center"><?php echo $children[2]->title; ?></h5>
<p class="light"><?php custom_echo($children[2]->body, 200); ?></p>
</div>
</div>
</div>
</div>
</div>
</div>
Also as the screen gets smaller in size you may want to have the cards adjust to medium and small devices, instead of having 3 cards in a row on small and medium devices, which is why the text gets bunched and becomes not so user friendly. You could do something like this to always keep the width of the cards very close. The only downside is if you don't want the cards to stack as it gets smaller.
<div class="row">
<!-- notice columns for each device size - small - medium -large -->
<div class="col s10 offset-s1 m6 l4">
<div class="card">
<div class="card-content">
<div class="icon-block">
<!-- I changed the size of the icon to .medium -->
<!-- Sizes you can use .tiny .smal .medium .large -->
<h2 class="center brown-text"><i class="material-icons medium">flash_on</i></h2>
<!-- give the card-title class to your titles -->
<div class="card-title">
<h5 class="center">Title</h5>
</div>
<p class="light">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc molestie placerat diam, eu dignissim massa aliquam eget. Proin nunc mauris, convallis ut felis rutrum, tempor pharetra magna. Fusce at sollicitudin neque, in mollis quam. Etiam finibus
a erat rutrum pellentesque.</p>
</div>
</div>
</div>
</div>
<!-- notice columns for each device size - small - medium -large -->
<div class="col s10 offset-s1 m6 l4">
<div class="card ">
<div class="card-content">
<div class="icon-block">
<!-- I changed the size of the icon to .medium -->
<!-- Sizes you can use .tiny .smal .medium .large -->
<h2 class="center brown-text"><i class="material-icons medium">group</i></h2>
<!-- give the card-title class to your titles -->
<div class="card-title">
<h5 class="center">Title</h5>
</div>
<p class="light">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc molestie placerat diam, eu dignissim massa aliquam eget. Proin nunc mauris, convallis ut felis rutrum, tempor pharetra magna. Fusce at sollicitudin neque, in mollis quam. Etiam finibus
a erat rutrum pellentesque.</p>
</div>
</div>
</div>
</div>
<!-- notice columns for each device size - small - medium -large -->
<!-- 0n medium size it offsets this card to center it on the next row keeping all cards the same size no matter the row -->
<div class="col s10 offset-s1 m6 offset-m3 l4">
<div class="card ">
<div class="card-content">
<div class="icon-block">
<!-- I changed the size of the icon to .medium -->
<!-- Sizes you can use .tiny .smal .medium .large -->
<h2 class="center brown-text"><i class="material-icons medium">settings</i></h2>
<!-- give the card-title class to your titles -->
<div class="card-title">
<h5 class="center">Title</h5>
</div>
<p class="light">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc molestie placerat diam, eu dignissim massa aliquam eget. Proin nunc mauris, convallis ut felis rutrum, tempor pharetra magna. Fusce at sollicitudin neque, in mollis quam. Etiam finibus
a erat rutrum pellentesque.</p>
</div>
</div>
</div>
</div>
</div>
Working Example
If the problem still persists update your question with the your css.

Make bootstrap columns all same height when structured in different rows?

The bootstrap grid layout below shows that in its large configuration, there are 9 elements, arranged like this:
[Glyph 1] [Glyph 2] [Glyph 3]
[Title 1] [Title 2] [Title 3]
[Text 1] [Text 2] [Text 3]
The text boxes have a coloured background. I would like this coloured background to be the same size for each text box, even when there are more lines of text in one of the boxes. It looks as though .row-eq-height would be a good start, but of course all my large text divs aren't in the same row and there are other divs in the rows too.
<div class="container-fluid PageView text-center">
<div class="row Page2">
<div class="col-sm-4">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-bullhorn glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-4">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-ok glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-4">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-phone glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-4">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h2><strong>Title 1</strong></h2>
</div>
<div class="col-xs-6 col-sm-12">
<p class="lead">Text 1</p>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h2><strong>Title 2</strong></h2>
</div>
<div class="col-xs-6 col-sm-12">
<p class="lead">Much Longer text, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sed turpis quis lacus sagittis aliquam mollis at ipsum. Ut a blandit metus, et aliquet nunc. Ut commodo lorem tortor, ullamcorper.</p>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h2><strong>Title 3</strong></h2>
</div>
<div class="col-xs-6 col-sm-12">
<p class="lead">Text 3</p>
</div>
</div>
</div>
</div>
</div>
</div>
Any Suggestions would be much appreciated.
Sorry about the last post, you can use Jquery to get even heights.
P:S does not work well in the code snippet. Probably coz not added the bootstrap JS library
$(document).ready(function() {
var h = new Array();
h[0] = $(".eqheight1").height();
h[1] = $(".eqheight2").height();
h[2] = $(".eqheight3").height();
var largest = h.sort(function(a, b) {
return a - b
}).slice(-1);
$(".eqheight3,eqheight2,.eqheight1").height(largest);
});
.eqheight1,
.eqheight2,
.eqheight3 {
background: #cfcfcf;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid PageView text-center">
<div class="row Page2">
<div class="col-sm-4">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-bullhorn glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-4">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-ok glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-4">
<div class="glyphicon-ring"> <span class="glyphicon glyphicon-phone glyphicon-bordered"></span>
</div>
</div>
<div class="col-sm-4">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h2><strong>Title 1</strong></h2>
</div>
<div class="col-xs-6 col-sm-12 eqheight1">
<p class="lead">Text 1</p>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h2><strong>Title 2</strong></h2>
</div>
<div class="col-xs-6 col-sm-12 eqheight2">
<p class="lead">Much Longer text, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sed turpis quis lacus sagittis aliquam mollis at ipsum. Ut a blandit metus, et aliquet nunc. Ut commodo lorem tortor, ullamcorper.</p>
</div>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="box">
<div class="row">
<div class="col-xs-6 col-sm-12">
<h2><strong>Title 3</strong></h2>
</div>
<div class="col-xs-6 col-sm-12 eqheight3">
<p class="lead">Text 3</p>
</div>
</div>
</div>
</div>
</div>
</div>