so I am trying to get my posts to be in a grid layout. I will try and demonstrate best I can with where I am at. So the posts are going to want to be in mosaic tiles. I am using this to achieve it:
http://sapegin.github.io/jquery.mosaicflow/
Now because I am building this locally it is difficult to show a live example. I have placed the files within my Wordpress theme and the html page works as per the files to the mosaic demo, yet when I bring the exact same code into a Wordpress page all of the images just sit down the left hand side and not tiling out.
I have removed my style sheets (it is blank anyway) so there is no conflict there. I have tried moving the link to the jQuery and the Javascript files but still no idea? Perhaps I am missing something?
so here is my homepeage code:
<?php get_header(); ?>
<!--<div id="site-description"><?php bloginfo( 'description' ); ?></div>-->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'entry' ); ?>
<?php comments_template(); ?>
<?php endwhile; endif; ?>
<?php get_template_part( 'nav', 'below' ); ?>
<style>
* {
margin:0;
padding:0;
box-sizing:border-box;
}
body {
font-family:"Helvetica Neue", Arial, sans-serif;
}
.mosaicflow__column {
float:left;
}
.mosaicflow__item {
position:relative;
}
.mosaicflow__item img {
display:block;
width:100%;
max-width:500px;
height:auto;
}
.mosaicflow__item p {
position:absolute;
bottom:0;
left:0;
width:100%;
margin:0;
padding:5px;
background:hsla(0,0%,0%,.5);
color:#fff;
font-size:14px;
text-shadow:1px 1px 1px hsla(0,0%,0%,.75);
opacity:0;
-webkit-transition: all 0.4s cubic-bezier(0.23,1,0.32,1);
-moz-transition: all 0.4s cubic-bezier(0.23,1,0.32,1);
-o-transition: all 0.4s cubic-bezier(0.23,1,0.32,1);
transition: all 0.4s cubic-bezier(0.23,1,0.32,1);
}
.mosaicflow__item:hover p {
opacity:1;
}
</style>
<div class="mosaicflow" data-item-height-calculation="attribute">
<div class="mosaicflow__item">
<img width="300" height="300" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-08-20_5D_1287_Artem_Sapegin.jpg" alt="">
<p>Dessi the Dachshund</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="200" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-08-24_5D_2066_Artem_Sapegin.jpg" alt="">
<p>Tsiri on Baltic Sea</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="300" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-10-21_5D_3178_Artem_Sapegin.jpg" alt="">
<p>Ciyar the Saluki</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="200" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-08-26_5D_2551_Artem_Sapegin.jpg" alt="">
<p>Tsiri Having Fun by the Sea</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="200" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-08-26_5D_2323_Artem_Sapegin.jpg" alt="">
<p>Dessi Meets the Sea</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="200" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-05-19_5D_9670_Artem_Sapegin.jpg" alt="">
<p>Tsiri the Saluki</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="200" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-08-20_5D_1165_Artem_Sapegin.jpg" alt="">
<p>Dessi on a Waterfall</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="200" src="http://sapegin.github.com/jquery.mosaicflow/img/2011-05-28_5D_4035_Artem_Sapegin.jpg" alt="">
<p>Dessi in Dandelion Field</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="300" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-12-09_5D_3758_Artem_Sapegin.jpg" alt="">
<p>New Year Postcard from Tsiri and Ciyar</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="300" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-10-21_5D_3422_Artem_Sapegin.jpg" alt="">
<p>Beautiful Afghan Hound Girl</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="300" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-10-21_5D_3414_Artem_Sapegin.jpg" alt="">
<p>Running Ciyar and Afgan Girl</p>
</div>
<div class="mosaicflow__item">
<img width="300" height="300" src="http://sapegin.github.com/jquery.mosaicflow/img/2012-08-26_5D_2378_Artem_Sapegin.jpg" alt="">
<p>Dessi Walking on a Sea Shore</p>
</div>
</div>
<script src="jquery.mosaicflow.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!--<?php get_sidebar(); ?>-->
<?php get_footer(); ?>
You need to call jQuery before you call the mosaic flow library, that should fix it.
Related
I'm trying to create a simple page with CSS Grid.
The result is pretty good before inserting a php function with MySQL.
CSS
.thumbnail
{
margin-bottom: 20px;
padding: 0px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 5px;
width: 350px;
}
HTML/PHP
<div class="container text-center">
<br>
<div class="item col-lg-4">
<div class="thumbnail">
<br>
<?php if ($fetch['file_name'] == '') { ?>
<img class="img-fluid" src="../images/missing.png" alt="Sample image" style="height:150px; width:150px;">
<?php } else { ?>
<img class="img-fluid" src="../images/<?php echo $fetch['file_name']; ?>" alt="missing.png" style="height:150px; width:150px;"/>
<?php } ?>
<div class="caption">
<h4><?php echo $fetch['school_name']; ?></h4>
<p><?php echo $fetch['email']; ?></p>
<p class="lead">$21.000</p>
<a class="btn2" href="profileorg.php?Org_ID=<?php echo $fetch['Org_ID'] ?>">View profile</a>
</div>
</div>
</div>
<?php } ?>
</div>
The screenshot is below
This is my problem:
After inserting php function
What I want is grid align like this:
Reference
<div class="container text-center">
<br>
<div class="item col-lg-4">
<div class="thumbnail">
<br>
<?php if ($fetch['file_name'] == '') { ?>
<img class="img-fluid" src="../images/missing.png" alt="Sample image" style="height:150px; width:150px;">
<?php } else { ?>
<img class="img-fluid" src="../images/<?php echo $fetch['file_name']; ?>" alt="missing.png" style="height:150px; width:150px;"/>
<?php } ?>
<div class="caption">
<h4><?php echo $fetch['school_name']; ?></h4>
<p><?php echo $fetch['email']; ?></p>
<p class="lead">$21.000</p>
<a class="btn2" href="profileorg.php?Org_ID=<?php echo $fetch['Org_ID'] ?>">View profile</a>
</div>
</div>
</div>
</div>
probably its because you have inserted extra closing braces. This code will work fine you.
I am using one snippet.now i need to loop this snippet with database value.how to achieve this?following is my snippet
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<style type="text/css">
/* image thumbnail */
.thumb {
display: block;
width: 100%;
margin: 0;
}
/* Style to article Author */
.by-author {
font-style: italic;
line-height: 1.3;
color: #aab6aa;
}
/* Main Article [Module]
-------------------------------------
* Featured Article Thumbnail
* have a image and a text title.
*/
.featured-article {
width: 482px;
height: 350px;
position: relative;
margin-bottom: 1em;
}
.featured-article .block-title {
/* Position & Box Model */
position: absolute;
bottom: 0;
left: 0;
z-index: 1;
/* background */
background: rgba(0,0,0,0.7);
/* Width/Height */
padding: .5em;
width: 100%;
/* Text color */
color: #fff;
}
.featured-article .block-title h2 {
margin: 0;
}
/* Featured Articles List [BS3]
--------------------------------------------
* show the last 3 articles post
*/
.main-list {
padding-left: .5em;
}
.main-list .media {
padding-bottom: 1.1em;
border-bottom: 1px solid #e8e8e8;
}
</style>
<script>
</script>
</head>
<body>
<div class="container">
<div class="row">
Articale post
</div>
<div class="row">
<div class="col-md-5 col-lg-5">
<!-- artigo em destaque -->
<div class="featured-article">
<a href="#">
<img src="http://placehold.it/482x350" alt="" class="thumb">
</a>
<div class="block-title">
<h2>Lorem ipsum dolor asit amet</h2>
<p class="by-author"><small>By Jhon Doe</small></p>
</div>
</div>
<!-- /.featured-article -->
</div>
<div class="col-md-7 col-lg-7">
<ul class="media-list main-list">
<li class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/150x90" alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">Lorem ipsum dolor asit amet</h4>
<p class="by-author">By Jhon Doe</p>
</div>
</li>
<li class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/150x90" alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">Lorem ipsum dolor asit amet</h4>
<p class="by-author">By Jhon Doe</p>
</div>
</li>
<li class="media">
<a class="pull-left" href="#">
<img class="media-object" src="http://placehold.it/150x90" alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">Lorem ipsum dolor asit amet</h4>
<p class="by-author">By Jhon Doe</p>
</div>
</li>
</ul>
</div>
</div>
</body>
</html>
Now i need to loop latest post from database and first post must display big image as 482*350 and next posts must be in the side (150*150).Any help is appreciated.
Updated::
Post table
id|post_title|post_description|featured_image|author_id|created_at|updated_at
In your Controller you need to fetch the first article and the 3 other ones:
$posts = Posts::orderBy('created_at')->take(4)->get();
$firstPost = $posts->pop();
return view('home', compact('firstPost', 'posts');
In your template file you can loop through them:
<div class="row">
<div class="col-md-5 col-lg-5">
<!-- artigo em destaque -->
<div class="featured-article">
<a href="#">
<img src="{{ $firstPost->featured_image }}" alt="" class="thumb">
</a>
<div class="block-title">
<h2>{{ $firstPost->post_title }}</h2>
<p class="by-author"><small>By {{ $firstPost->author->name }}</small></p>
</div>
</div>
<!-- /.featured-article -->
</div>
<div class="col-md-7 col-lg-7">
<ul class="media-list main-list">
#foreach($posts as $post) {
<li class="media">
<a class="pull-left" href="#">
<img class="media-object" src="{{ $post->featured_image" alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">{{ $post->post_title }}</h4>
<p class="by-author">By {{ $post->author->names }}</p>
</div>
</li>
#endforeach
</ul>
</div>
</div>
In your Post Model you need a relationship to the author, e.g.
Class Posts extends Model {
public function author {
return $this->hasOne('App\Author');
}
}
I'm using a custom Wordpress theme which is Goblog theme, in which a slider is included (it's not a plugin). The slider worked fine untile one day it stoped working correctly. The only change I could have done about the slider was editing the CSS to add more height, which, I think, isn't the cause of this issue.
Basically everything works great on the slider, unless that the permalinks does not match with the content, and when clicked on, it redirects to another article.
Here is the php for the slider :
<?php if($bpxl_goblog_options['bpxl_home_slider'] == '1') { ?>
<div class="featuredslider flexslider loading">
<ul class="slides">
<?php
$slider_cat = '';
if(!empty($bpxl_goblog_options['bpxl_home_slider_cat'])) {
$slider_cats = $bpxl_goblog_options['bpxl_home_slider_cat'];
$slider_cat = implode(",", $slider_cats);
}
$slider_query = new WP_Query("cat=".$slider_cat."&orderby=date&order=DESC&showposts=3");
?>
<?php if($slider_query->have_posts()) : while ($slider_query->have_posts()) : $slider_query->the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" class="featured-thumbnail featured-widgetslider">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('featured');
} else {
echo '<img src="' . get_stylesheet_directory_uri() . '/images/770x360.png" />';
}
?>
<div class="post-inner textcenter">
<header>
<h2 class="title title22">
<?php the_title(); ?>
</h2>
<div class="slider-meta" style="display:none;"><span><?php _e('Ecrit par'); ?></span> <?php the_author(); ?></div>
</header><!--.header-->
</div>
</a>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
<?php } ?>
The ouput HTML of the current slider (without editing) :
<div class="featuredslider flexslider">
<ul class="slides">
<li style="width: 100%; float: left; margin-right: -100%; position: relative; opacity: 0; display: block; z-index: 1;" class="">
<a href="http://db-super.fr/episode-6-vostfr-dragon-ball-super/" title="Dragon Ball Super : Episode 6 VOSTFR" class="featured-thumbnail featured-widgetslider">
<img width="770" height="360" src="http://db-super.fr/wp-content/uploads/2015/08/DBSUPER-Episode-6-screen-6-770x360.jpg?7ac485" class="attachment-featured wp-post-image" alt="Beerus" draggable="false"> <div class="post-inner textcenter">
<header>
<h2 class="title title22">
Title </h2>
<div class="slider-meta" style="display:none;"><span>Ecrit par</span></div>
</header><!--.header-->
</div>
</a>
</li>
<li style="width: 100%; float: left; margin-right: -100%; position: relative; opacity: 0; display: block; z-index: 1;" class="">
<a href="http://db-super.fr/episode-5-vostfr-dragonball-super/" title="Dragon Ball Super : Episode 5 VOSTFR" class="featured-thumbnail featured-widgetslider">
<img width="770" height="360" src="http://db-super.fr/wp-content/uploads/2015/08/dbsuper-episode-5-770x360.jpg?7ac485" class="attachment-featured wp-post-image" alt="dbsuper episode 5" draggable="false"> <div class="post-inner textcenter">
<header>
<h2 class="title title22">
Title</h2>
<div class="slider-meta" style="display:none;"><span>Ecrit par</span></div>
</header><!--.header-->
</div>
</a>
</li>
<li style="width: 100%; float: left; margin-right: -100%; position: relative; opacity: 1; display: block; z-index: 2;" class="flex-active-slide">
<a href="http://db-super.fr/marathon-dragonball-z-cinema-grand-rex/" title="Marathon Dragon Ball Z au cinéma Le Grand Rex" class="featured-thumbnail featured-widgetslider">
<img width="770" height="360" src="http://db-super.fr/wp-content/uploads/2015/08/fukkatu-770x360.jpg?7ac485" class="attachment-featured wp-post-image" alt="fukkatu" draggable="false"> <div class="post-inner textcenter">
<header>
<h2 class="title title22">
Title</h2>
<div class="slider-meta" style="display:none;"><span>Ecrit par</span></div>
</header><!--.header-->
</div>
</a>
</li>
</ul>
<ol class="flex-control-nav flex-control-paging"><li><a class="">1</a></li><li><a class="">2</a></li><li><a class="flex-active">3</a></li></ol><ul class="flex-direction-nav"><li><a class="flex-prev" href="#"><i class="fa fa-angle-left"></i></a></li><li><a class="flex-next" href="#"><i class="fa fa-angle-right"></i></a></li></ul></div>
I thought this might be a permalink issue, so I reloaded them. Also thinking it could be a cache issue I tried to desactivate some plugins that could interacts with the slider.
That's why I finally thought this issue came from the php code itself, unfortunately I didn't figured out where was the issue.
Any ideas of what is causing this problem ?
Edit : you can watch the slider here db-super .fr
Edit 2 : This issue is still not solved and i'm still looking for the cause of this problem.
Please try to Replace following line:
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" class="featured-thumbnail featured-widgetslider">
with this one:
<a href="<?php echo esc_url(get_permalink()); ?>" title="<?php the_title_attribute(); ?>" class="featured-thumbnail featured-widgetslider">
So I am working to make a change on this site. http://www.kbduct.com . One the site there is a png file of a transparent united states logo on the front. I had to add a small awfs logo banner to it and have the viewer be able to click on it so that it can lead to a different site. I added the anchor tags to these items but nothing happens wen you click on it. Heres the index file and the external file for the image.
BTW, I didn't build this site. Im helping to maintain it for the time being.
INDEX:
<?php include('inc/default.php');
$pageTitle = "The Nations Source For Industrial Ducting, Ducts and Ductwork Components - KB Duct";
$pageDisc = "KB Duct is the Nation's source for industrial duct, ducting components and ductwork fittings and supplies. We offer custom built solutions for your industrial needs.";
$pageKeys = "duct, ductwork, ducting, duct work, commercial ducting, industrial ducting, custom ductwork, ductwork supplies, ducting accessories, duct fittings";
?>
<!doctype html>
<html>
<?php include('inc/head.php'); ?>
<body>
<div id="sb-site">
<?php include('inc/maximage.php'); ?>
<?php include('inc/header.php'); ?>
<div class="mainarea">
<a href="http://awfsfair.org/">
<div id="eBanner" style=" position: absolute; right: 380px; top: 310px;">
<?php /*?> <script type='text/javascript' src='http://libs.a2zinc.net/Common/JS/10.6.0.0/a2zWidget.js'></script><script type='text/javascript' id='exWidget'>new a2z.Widget('dGbJ%2fQfPqUA4s%2fDNrIc%2fzt5xiq%2fL4ZoFjVXmdUEcJutOcD9ggxZSCZyU8MZ6cQu6',40297,'http://libs.a2zinc.net/Common/Widgets/ExhibitorBadge.aspx',31,201133,330,200).render();</script>
<?php */?>
</a>
</div>
<div class="wrapper">
<?php include('inc/industry.php'); ?>
<?php include('inc/catatypes.php'); ?>
<div id="mob-only">
<?php include('inc/mobslideup.php'); ?>
</div>
</div>
</div>
<?php include('inc/footer.php'); ?>
</div>
<?php include('inc/mob-menu.php'); ?>
</body>
</html>
MAXIMAGE.PHP:
<div id="maximage">
<div>
<img src="img/Custom-Ductwork-Clamp-Together-Ducting-Shiny-Ducts-BG.jpg" alt="KB Duct is the nation's source for clamp together and flanged industrial ducting and duct parts." />
<div class="in-slide-content" style="display:none;">
<img src="img/nations-source-for-industrial-ducting.png" alt="KB Duct offers custom fabricated industrial ducting solutions.">
</div>
</div>
<div>
<img src="img/shinyduct.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
<!-- <div>
<img src="img/kbduct-production.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/nations-source-for-industrial-ducting.png">
</div>
</div>-->
<div>
<img src="img/plasma.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
<div>
<img src="img/welding.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
<!-- <div>
<img src="img/clamp.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/nations-source-for-industrial-ducting.png">
</div>
</div>-->
<div>
<img src="img/tunnel.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
MAXIMAGE CSS ID:
#maximage {
display:block;/* Only use this if you fade it in again after the images load */
position:fixed !important;
z-index:-1;
CSS IN SLIDE CONTENT:
.in-slide-content {
color:#333;
float:right;
font-family:'Helvetica Neue', helvetica;
font-size:60px;
font-weight:bold;
right:20px;
margin:40px;
padding:20px;
position:absolute;
top:20px;
width:700px;
z-index:9999; /* Show above .gradient */
text-shadow: 0 1px 0 #fff;
-webkit-font-smoothing:antialiased;
}
I did some R&D got some thing. May be this help you
There is a id eBanner change inline styling to
position: absolute;
right: 269px;
top: 141px;
z-index: 9999;
height: 100px;
width: 185px;
border: 2px solid red;
Inside this div there is and anchor tag add folloing style
display: block;
width: 181px;
height: 100px;
Once you check it works then you can remove red border
I use the following code:
.contain {
max-width: 960px;
text-align: center;
}
.category {
position: relative;
display: inline-block;
float: left;
padding: 10px;
}
<div align="center" class="category">
<img src="img/Tariffs-Booking-Icon.png" style="width:100; height:60px;margin-right: 124px;" />
</div>
<div align="center" class="category">
<img src="img/driver_icon.jpg" style="width:100; height:100px;margin-right:124px;" />
</div>
<div align="center" class="category">
<img src="img/user.png" style="width:100; height:100px" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" style="width:100; height:100px;margin-left:58px;" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" style="width:100; height:100px;" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" style="width:100; height:100px;" />
</div>
I am unable to display three images in one rows and in second row next three images.
but i got the images in one rows. so there is any possibility to show images like as in one
row 1 2 3 and second row 4 5 6 images.
Thanks and regards
Add clear: left; to .category:nth-child(4)
JSFiddle - DEMO
.category:nth-child(4) {
clear: left;
}
The clear CSS property specifies whether an element can be next to
floating elements that precede it or must be moved down (cleared)
below them. - by Mozilla MDN
The easiest way would be to have one div for each row and each div having just those 3 images inside them.
<div align="center" class="category">
<img src="img/Tariffs-Booking-Icon.png" />
<img src="img/driver_icon.jpg" />
<img src="img/user.png" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" />
<img src="img/abuse.jpg" />
<img src="img/abuse.jpg" />
</div>
See it here: http://jsfiddle.net/vj4kLdjh/1/
A slightly better approach would be to wrap each row into another div what would have display set to block (default) and the inside divs should either lose the float, or you need to add a clear:both element to the end of each row.
<div class="row>
<div align="center" class="category">
<img src="img/Tariffs-Booking-Icon.png" />
</div>
<div align="center" class="category">
<img src="img/driver_icon.jpg" />
</div>
<div align="center" class="category">
<img src="img/user.png" />
</div>
</div>
<div class="row>
<div align="center" class="category">
<img src="img/abuse.jpg" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" />
</div>
</div>
See it here: http://jsfiddle.net/vj4kLdjh/2/
I've marked the rows with a red border in both cases. I've also removed the inline styling in my answer, and I suggest you do the same in your code. Define classes for those elements and avoid inline styling whenever possible.
This will do exactly what you need - 2 rows containing 3 pictures each to 960px (Which you can of course modify). Don't forget that the child element (category) is width + padding(x2) for actual width - in this case, 320px each.
CSS:
div.contain {
width:960px;
}
# Each div takes 320px (times 3 is 960px)
div.category {
display: inline-block;
padding:5px;
width: 310px;
}
Then
<div class="contain">
<div class="category"># image 1</div>
<div class="category"># image 2</div>
<div class="category"># image 3</div>
</div>
<div class="contain">
<div class="category"># image 4</div>
<div class="category"># image 5</div>
<div class="category"># image 6</div>
</div>
You have to add a wrapper div to each row as:
.row_wrap {
width: 100%;
display: inline-block;
}
.contain {
max-width: 960px;
text-align: center;
}
.category {
position: relative;
display: inline-block;
float: left;
padding: 10px;
}
<div class="row_wrap">
<div align="center" class="category">
<img src="img/Tariffs-Booking-Icon.png" style="width:100; height:60px;margin-right: 124px;" />
</div>
<div align="center" class="category">
<img src="img/driver_icon.jpg" style="width:100; height:100px;margin-right:124px;" />
</div>
<div align="center" class="category">
<img src="img/user.png" style="width:100; height:100px" />
</div>
</div>
<div class="row_wrap">
<div align="center" class="category">
<img src="img/abuse.jpg" style="width:100; height:100px;margin-left:58px;" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" style="width:100; height:100px;" />
</div>
<div align="center" class="category">
<img src="img/abuse.jpg" style="width:100; height:100px;" />
</div>
</div>
Hope this helps
div{
width: 400px;
}
div>img{
width: 100px;
float: left;
}
div>img:nth-child(3n+1){
clear: left;
}
<div>
<img src="1.jpg"/>
<img src="1.jpg"/>
<img src="1.jpg"/>
<img src="1.jpg"/>
<img src="1.jpg"/>
<img src="1.jpg"/>
</div>