col one_third without col_last

8 replies·opened May 13, 2016
S
spidometrsMay 13, 2016

I use this code:

<div class="container clearfix">

  {foreach name=kbasecats from=$kbcats item=kbcat}
					<div class="col_one_third">
						<div class="feature-box fbox-rounded fbox-effect">
							<div class="fbox-icon">
								<a href="/knowledgebase/{$kbcat.id}"><i class="icon-screen i-alt"></i></a>
							</div>
							<h3>{$kbcat.name} <span class="badge">{$kbcat.numarticles}</span></h3>
							<p>{$kbcat.description}</p>
						</div>
					</div>  

  {/foreach}

</div>

I must place the information in two columns.
My CMS generates categories: Title, Description.
I can not to add some categories col_last, and for other categories do not add col_last.
Or are always without col_last, or always col_last.

Because of this, the conclusion of categories broken.
See screenshot.

You can fix it to the category are placed evenly on the page?

S
SemiColonWebSTAFFMay 13, 2016

Hello,

This is Definitely Possible. You can either use the Bootstrap Grid which will work seamlessly or you will need to use some programmable logic with the Custom Grid. Try using the following logic:

<?php

	$col = 0;

	$col++;

	if( $col % 3 == 0 ) {
		$class = " col_last";
	} else {
		$class = "";
	}

	echo '<div class="col_one_third' . $class . '">Column</div>';

?>

This will definitely work fine. Let us know if we can help you with anything else or if you find any further issues.

S
spidometrsMay 13, 2016

I added logic.
I want to get two columns, but I always get three columns.
See a screenshot of the result.
How can I make two columns?

S
spidometrsMay 15, 2016

The problem is not solved.
Can you help me?

S
SemiColonWebSTAFFMay 16, 2016

Hello,

Please consider using something like this:

<?php

	$col = 0;

	$col++;

	if( $col % 2 == 0 ) {
		$class = ' col_last';
		$clear = '<div class="clear"></div>';
	} else {
		$class = '';
		$clear = '';
	}

	echo '<div class="col_half' . $class . '">Column</div>' . $clear;

?>
S
spidometrsMay 16, 2016

It breaks the page for desktop computers.
See screenshot 1.

If I change
col_half {
width: 48%;
}
on
width: 33.33%;
Then it works well for desktop computers, but does not work for mobile devices.
See screenshot 2.

How can I fix this? For mobile devices, it should look like the screenshot 3.
This should work for all devices.

Thank you!

S
spidometrsMay 16, 2016

screenshot 3

S
SemiColonWebSTAFFMay 17, 2016

Hello,

We have just noticed through the Inspect Element in the Screenshots that there is a Serious Error in your Code. You are using the .container Wrapper inside the .postcontent Element which is Highly Incorrect. The .container Wrappers are only used inside Full Width Layouts. Please delete the .container Container and use the Grids as it is without modifying the Grid Widths through CSS. This should automatically fix your issue.

Let us know if we can help you with anything else or if you find any further issues.

S
spidometrsMay 17, 2016

Yes, now everything works great!
Many thanks!
You make excellent support!

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard