Center float except last row - php

I need to center some floated divs inside a container. The code I'm using works but I need the last row of floated elements to be aligned to the left and not centered. It's a photo album and all the thumbnails are automatically generated by a gallery script.
This is what the code produces
This is what I need
I don't think this is possible with css alone, maybe some jquery or php...
CSS
#gallery {
background-color: #ffffff;
border: 1px solid #999999;
margin: 0 auto;
overflow: hidden;
position: relative;
text-align: center;
width: 750px;
}
.image {*display:inline;
background: #F7F9FD;
border: 1px solid #E7F0F5;
display: -moz-inline-stack;
display: inline-block;
line-height: 100%;
margin: 1em;
padding: 0;
text-align:left;vertical-align:top;
zoom:1;
}
.imagethumb a, .imagethumb a:hover {
border:0;
display: block;
margin: 5px;
}
.imagethumb {float: left;}
.clear {clear: both}
The PHP code
<div id="gallery">
<?php while (next_image(false, $firstPageImages)): ?>
<div class="image">
<div class="imagethumb">
<?php printImageThumb(getAnnotatedImageTitle()); ?>
</div>
</div>
<?php endwhile; ?>
</div>
Generated html
<div id="gallery">
<div id="images">
<div class="image">
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
</div>
<div class="image">
<div class="imagethumb"><img src="/zen/cache/p101-02_110_thumb.jpg" alt="p101-02" /></div>
</div>
<div class="image">
<div class="imagethumb"><img src="/zen/cache/p101-04_110_thumb.jpg" alt="p101-04" /></div>
</div>
[...]
</div>

Not sure what you are doing with all those nast hacks.. no jquery or php needed. just css.
This works fine for me. I did add widths and heights on the images because I didn't feel like actually getting an image. buts its all the same.
CSS
#gallery { background-color: #fff; border: 1px solid #999; margin: 0 auto; overflow: hidden; position: relative; text-align: center; width: 750px; }
.imagethumb a,
.imagethumb a:hover { border:0; display: block; margin: 5px; }
.imagethumb {float: left; margin:5px; background: #F7F9FD; border: 1px solid #E7F0F5; width:100px; height:200px;}
.clear {clear: both}
HTML Final Output
<div id="gallery">
<div id="images">
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
<div class="imagethumb"><img src="/zen/cache/p101-01_110_thumb.jpg" alt="p101-01" /></div>
</div>
<div class="clear"></div>
</div>

You could just align left the whole thing with a left-padding and achieve the same result.
Or, you could align left everything and place it in another div container that is centered.

Related

How can I get my header elements to line up in a row properly?

I've designated a background image for the whole page. On top of this I would like to have a header, with a solid background color, with my logo on the left side, business name in the middle, and my name on the right side.
Below this I would like 3 columns for the main page of my site, each probably with their own background color if that's possible.
I'm trying to use bootstrap to give my header three sections (logo-text-name), and I'd like the text to be centred.
The reason I have so much padding is because the logo kept hanging out the bottom of the header.
Now I'm sure there's a lot I'm doing wrong, but if anyone could help I'd be eternally grateful. Thanks.
body {
background-image: url(images/bg.jpg);
}
header {
background-color: #539e8a;
padding: 20px 10px 30px 10px;
color: #f6c5be;
border-radius: 25px;
margin-top: 10px;
height: 180px;
}
#logo {
width: 160px;
height: 140px;
float: left;
}
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<header>
<div class="container">
<div class="row">
<div class="col-xs-2">
<img id="logo" src="https://via.placeholder.com/160x140" alt="cakes 'n' bakes logo">
</div>
<div class="col-xs-8">
<h1>Cakes 'n' Bakes</h1>
</div>
<div class="col-xs-2">
<p>my name</p>
</div>
</div>
</div>
</header>
<div class="container">
<div id="main" class="row">
<div id="col1" class="col-sm-4">
<h2> col 1 </h2>
</div>
<div id="col2" class="col-sm-4">
<h2> col 2 </h2>
</div>
<div id="col3" class="col-sm-4">
<h2> col 3 </h2>
</div>
</div>
</div>
</body>
Bootstrap 5 really brings flexbox to the table, so I'd use that rather than wrestling with columns, which can be troublesome due to inflexibility.
Here I've replaced your container, row, and columns with a simple flex row. Item alignment on the cross axis centers things up. The center element has Bootstrap's flex-fill class on it to make it stretch.
Also notice that I've replaced your custom margin and padding with Bootstrap
spacing classes to clean things up.
body {
background-image: url(https://via.placeholder.com/1200);
}
header {
background-color: #539e8a;
color: #f6c5be;
border-radius: 25px;
}
#logo {
width: 160px;
height: 140px;
}
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<header class="mt-3">
<div class="d-flex align-items-center">
<img id="logo" src="https://via.placeholder.com/160x140" alt="cakes 'n' bakes logo" class="logo m-3">
<div class="flex-fill text-center">
<h1>Cakes 'n' Bakes</h1>
</div>
<div class="px-3">
<p>My Name</p>
</div>
</div>
</header>
<div class="container">
<div id="main" class="row">
<div id="col1" class="col-sm-4">
<h2> col 1 </h2>
</div>
<div id="col2" class="col-sm-4">
<h2> col 2 </h2>
</div>
<div id="col3" class="col-sm-4">
<h2> col 3 </h2>
</div>
</div>
</div>
</body>
I make some changes and add somethings to your code so I hope I hope I could help you!
body {
background-image: url(images/bg.jpg);
}
header {
background-color: #539e8a;
padding: 20px 10px 0px 0px;
color: #f6c5be;
border-radius: 25px;
margin-top: 10px;
height: 180px;
}
#logo {
width: 160px;
height: 140px;
}
#top-part-1 {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.col-xs-2 {
display: flex;
flex-direction: column;
justify-content: center;
}
.col-xs-8 {
display: flex;
flex-direction: column;
justify-content: center;
}
.header-2 {
padding: 20px 10px 0px 0px;
color: #000000;
border-radius: 25px;
margin-top: 10px;
height: 180px;
}
#top-part-2 {
display: flex;
flex-direction: row;
justify-content: space-between;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<header>
<div class="container" id="top-part-1">
<div class="col-xs-2">
<img id="logo" src="images/logo.png" alt="cakes 'n' bakes logo">
</div>
<div class="col-xs-8">
<h1>Cakes 'n' Bakes</h1>
</div>
<div class="col-xs-2">
<p>my name</p>
</div>
</div>
</header>
<div class="header-2">
<div class="container" id="top-part-2">
<div class="col-xs-2">
<h2> col 1 </h2>
</div>
<div class="col-xs-8">
<h2> col 2 </h2>
</div>
<div class="col-xs-2">
<h2> col 3 </h2>
</div>
</div>
</div>

Change class of the last instance of an item within a loop with WordPress/ACF

I want to insert an arrow image between each div with the class product-icon in a WordPress loop using the ::after CSS pseudo-element. Right now the arrow shows up after every product-icon div the loop populates, but I want it to be hidden after the last one (and the number of divs displayed changes depending which page you're on). I'm guessing I'll need to change the class of the last div in the loop, but I'm not sure how to do that. Here's an HTML version so you can see what it should look like:
<section id="case-study-product-overview" class="horizontal">
<div class="max-container">
<div id="product-map-container">
<div>
<div class="product-icon"><img src="https://cdn4.iconfinder.com/data/icons/basic-for-user-interface-vol-1/24/add-_plus-_create_-square-_Add_Button-512.png"><p class="icon-subtitle">Icon 1</p></div>
<div class="product-card">
<h3 class="product-overview-title green-text">Title 1</h3>
<img class="product-image" src="https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png">
<p class="blurb">Lorem ipsum dummy paragraph text.</p>
</div>
</div>
<div>
<div class="product-icon"><img src="https://cdn4.iconfinder.com/data/icons/basic-for-user-interface-vol-1/24/add-_plus-_create_-square-_Add_Button-512.png"><p class="icon-subtitle">Icon 2</p></div>
<div class="product-card">
<h3 class="product-overview-title green-text">Title 2</h3>
<img class="product-image" src="https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png">
<p class="blurb">Lorem ipsum dummy paragraph text.</p>
</div>
</div>
<div>
<div class="product-icon"><img src="https://cdn4.iconfinder.com/data/icons/basic-for-user-interface-vol-1/24/add-_plus-_create_-square-_Add_Button-512.png"><p class="icon-subtitle">Icon 3</p></div>
<div class="product-card">
<h3 class="product-overview-title green-text">Title 3</h3>
<img class="product-image" src="https://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/sign-check-icon.png">
<p class="blurb">Lorem ipsum dummy paragraph text.</p>
</div>
</div>
</div>
</div>
</section>
here's the PHP I am ACTUALLY working with:
<section id="case-study-product-overview" class="horizontal">
<div class="max-container">
<h2 class="cs-heading eaton-blue-text">Product Overview</h2>
<div id="product-map-container">
<?php if ( have_rows('product_overview_map') ): ?>
<?php while( have_rows('product_overview_map') ): the_row(); ?>
<div>
<!-- ** This line is what the arrow should come after, except the last one** -->
<div class="product-icon"><img src="<?php echo get_sub_field('product_overview_icon'); ?>"/>
</div>
<!-- -->
<p class="icon-subtitle"><?php echo get_sub_field('product_overview_icon_label'); ?></p>
<div class="product-card">
<h3 class="product-overview-title eaton-blue-text"><?php echo get_sub_field('product_title'); ?></h3>
<img class="product-image" src="<?php echo get_sub_field('product_image'); ?>" />
<p class="blurb"><?php echo get_sub_field('product_description'); ?></p>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</section>
and the CSS:
#case-study-product-overview .ecosystem-diagram {
min-height:650px;
margin-top:3%;
}
#case-study-product-overview .ecosystem-item {
position:absolute;
width:250px;
align-items:center;
margin-left:-125px;
margin-top:-100px;
}
#case-study-product-overview .image {
width:300px;
height:300px;
display:flex;
align-items:flex-end;
}
#case-study-product-overview .image img {
max-height:250px;
max-width:245px;
}
.product-icon::after {
content: url(http://wordpress-dev.tcc.etn.com/wordpress/iot/wp-content/uploads/sites/11/2019/07/arrows.png);
position: absolute;
top: 25px;
margin:0 32px;
}
.last-product-icon::after {
content:'';
}
.product-icon > img {
width: 50px;
height: 50px;
}
#product-map-container {
display: flex;
margin: 50px 0;
justify-content: center;
position: relative;
}
#product-map-container > div {
margin: 10px;
text-align: center;
}
.product-card {
box-shadow: 1px 1px 6px 1px #999;
max-width: 240px;
min-height: 475px;
padding: 10px;
}
.product-image {
width: 200px;
margin:auto;
}
Any help would be greatly appreciated. Thanks!

How To Change Header Photo Whene Slide

i use swiper slider to make a profile slide the javascript is standar like in this github
https://github.com/nolimits4web/Swiper/blob/master/demos/390-autoheight.html
this the picture from my page
i use like this for the header photo
<div class="row">
<div class="col-12 p-0">
<img class="kol1">
</div>
</div>
and this is for the text-box
<!--text-->
<div class="col-12 bg-text-kol">
<div class="swiper-container swiper2" >
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="text-left">
</br>
<h2 class="h5 mt-3"><?php echo $this->lang->line('kol_15_name'); ?></h2>
<?php echo '#'.$this->lang->line('kol_15_ig'); ?>
<p class="mark-bold"><?php echo $this->lang->line('kol_15_title'); ?></p>
<p class="mt-3"><?php echo $this->lang->line('kol_15_text'); ?></p>
</br>
</div>
</div>
</div>
<!-- Add Pagination-->
<div class="swiper-pagination"></div>
</div>
</div>
The slider text box is running well
my question is how do every time I do a slide photo header change every time I do a slide?
Here is a sample how you could integrate the image in your slider. The .text-left is positioned absolute inside the .testamonial container above all other content inside of it.
HTML Code:
<div class="swiper-slide">
<div class="testamonial">
<div class="banner">
Get your free Engrave
</div>
<div class="photo">
<img src="https://upload.wikimedia.org/wikipedia/en/8/88/MagooAndDog.jpg"/></div>
<div class="text-left">
<h2 class="h5 mt-3">Mr. Triples</h2>
#mr_triples
<p class="mark-bold">Content User</p>
<p class="mt-3">Not that much here.</p>
</div>
</div>
</div>
CSS Code:
.photo {
width: 300px;
height: 300px;
max-width: 300px;
overflow: hidden;
}
.banner {
background-color: orange;
padding: 5px;
}
.text-left {
text-align: left;
position: absolute;
width: 200px;
border-radius: 10px 10px 0px 0px;
background-color: rgba(255,255,255,0.8);
bottom: 0;
left: 30px;
padding: 10px;
padding-top: 20px;
min-height: 100px;
}
Here is a codepen to show you how your desired effect can be achieved.

Wordpress - CSS styling not applying on a row

I'm currently building a site on Wordpress using the html5blank as the parent theme. I've built all the front-end text pages on HTMl/CSS. When I've transferred all the files over a lot of the styling has broken - I've fixed the majority of it but there's one section that I cannot fix. This is how it should look -
And this is how it looks in the Wordpress site -
When I've inspected the site via developer tools it seems as though these rules are not being applied -
.agencyproducts {
position: relative;
display: inline-block;
text-align: center;
}
Also, the row in the front-end site is applying a height rule but not in the wordpress site. I've looked at applying specificity rules and !important but nothing (this also disrupts other styling rules on other parts of the site). I'm really stuck on this and would appreciate any assistance.
Here's the full code for the section -
section#products {
height: 800px;
max-width: 100%
}
.agencyproducts {
position: relative;
display: inline-block;
text-align: center;
}
.agencyproducts p {
text-align: center;
margin: 30px;
}
.agencyproducts img {
width: 70px;
height: 70px;
position: relative;
line-height: 1;
top: 50%;
}
figure {
text-align: center;
display: inline-block;
max-width: 80px;
height: 100px;
vertical-align: top;
margin: 5px;
font-size: 9px;
margin-bottom: 60px;
}
figure img {
padding-bottom: 5px;
}
.four {
padding: 0;
margin: 0;
border: 0;
}
.images {
margin-top: 30px;
border-bottom: 10px;
}
.images img {
margin-left: 20px;
padding: 10px;
}
.chevron {
height: 150px;
}
.chevron figcaption {
margin-top: 20px;
font-size: 13px;
color: #d3d3d3;
}
hr.hragency {
display: block;
width: 250px;
margin-top: 0em;
margin-bottom: 0em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
border-color: #F0F0F0;
}
<section id="products">
<div class="container">
<div class="row">
<div class="twelve columns agencyproducts">
<p>WHAT PRODUCT ARE YOU INTERESTED IN?</p>
<a href="2k4kproduction.html">
<figure>
<img src="images/production.png" alt="Production">
<figcaption>2K / 4K PRODUCTION</figcaption>
</figure>
</a>
<a href="postproduction.html">
<figure>
<img src="images/post-production.png" alt="Post-Production">
<figcaption>POST PRODUCTION</figcaption>
</figure>
</a>
<a href="2d3danimation.html">
<figure>
<img src="images/animation.png" alt="Animation">
<figcaption>2D / 3D ANIMATION</figcaption>
</figure>
</a>
<a href="adhoc.html"><figure>
<img src="images/ADHOC.png" alt="ADHOC">
<figcaption>ADHOC</figcaption>
</figure>
</a>
<a href="interactive.html">
<figure>
<img src="images/interactive.png" alt="Interactive">
<figcaption>INTERACTIVE & PERSONALISED</figcaption>
</figure>
</a>
<a href="tvadverts.html">
<figure>
<img src="images/tv-adverts.png" alt="TV ADVERTS">
<figcaption>TV ADVERTS</figcaption>
</figure>
</a>
<a href="360video.html"><figure>
<img src="images/360.png" alt="360 Video and VR">
<figcaption>360 VIDEO & VIRTUAL REALITY</figcaption>
</figure>
</a>
</div>
</div>
<hr class="hragency">
<div class="row">
<div class="images">
<div class="four columns">
<img src="images/VIDEO.jpg" alt="Video">
<img src="images/blog.jpg" alt="blog">
</div>
<div class="four columns">
<img src="images/faq.jpg" alt="FAQ">
<img src="images/VIDEO.jpg" alt="Video">
</div>
<div class="four columns">
<img src="images/blog.jpg" alt="blog">
<img src="images/faq.jpg" alt="FAQ">
</div>
</div>
</div>
</div>
</section>
<section class="chevron">
<div class="container">
<div class="row">
<figure>
<figcaption>SEE MORE</figcaption>
<i class="fa fa-chevron-circle-down fa-3x" aria-hidden="true"></i>
</figure>
</div>
</div>
</section>
Try this:
.agencyproducts{
width:100%;
text-align:center;
}
.agencyproducts a{
display:inline-block;
}
Because container .agencyproducts need to have text-align:center and first childs of it must be displayed as inline-block ... then they will display properly. You only set child of a tag as display:inline-block but do not tell CSS how it should treat it parent.
With what I understood try appending !important to your custom css properties so as to override any pre-existing style properties.
height: 150px !important;

how to append a div through JQuery like the eCommerce website on click or focus

This is my HTML code
<div>
<div class="text-center col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-md-3 col-sm-3 animate-box">
<div class="team-section-grid" style="background-image: url(assets/img/image-bg.jpg);">
<div class="overlay-section">
<div class="desc">
<i class="icon icon-wallet2"></i> Buy Now
</div>
</div>
</div>
<div class="text-center add-cart">
<a href="" title="">
<i class="icon icon-cart"></i> Add To Cart
</a>
<a href="" title="">
<i class="icon icon-heart" style="margin-left: 10px;"></i> Add To Wishlist
</a>
</div>
</div>
View More..
</div>
What i am trying to achieve through JQUery is whenever click the view more.. or whenever the focus is on that button I want the following div appended to the current div so that I can dynamically load products from the DB and append it.
Can anyone help me with that code? Thanks in advance..
Did you tried: http://api.jquery.com/append/ ?
A very simple example:
jQuery('.wrapper a').on('click', function(e){
e.preventDefault;
jQuery('.wrapper').append('<div class="item"></div>');
});
.wrapper{
position: relative;
background: #e6e6e6;
padding: 10px 10px 50px 10px;
}
.wrapper a{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 10px 0;
background: #aaa;
color: white;
text-align: center;
border-top: 3px solid #fff;
}
.item{
display: block;
width: 100%;
height: 20px;
background: #ccc;
margin: 0 0 5px 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="wrapper">
show more
<div class="item"></div>
</div>
Instead of append('<div class="item"></div>') you can append html-templates, too. It could be more comfortable to use a template engine here ...

Categories