How can I make Woocommerce Product Gallery Thumbnail Vertical - woocommerce

I am working on a woocommerce site. But can't make the product thumbnails align vertical.
I used woozoom plugin & all the thumbnails are in a 'jcarousel-wrapper'.

Cairo Web Design's solution works for the default installation, but if you are using the WooCommerce Storefront Power Pack extension, you need 3 additional pieces:
To the filters that change the column count, add a priority so they fire later.
Add additional elements to each CSS rule. See CSS below.
Add another css rule that moves the magnification icon to the left side. Otherwise, it covers the first thumbnail after vertically stacking.
Make a plugin or paste this into functions.php and it should work for installations that use the PowerPack Extension.
/*Based on Solution from Rodolfo Melogli*/
/* --- PHASE 1, make the gallery thumbnail column count 1 (not 3 or 4 )--- */
add_filter( 'woocommerce_product_thumbnails_columns', 'dk_single_gallery_columns', 99 );
function dk_single_gallery_columns() {
return 1;
}
// Do it for the Storefront theme specifically:
add_filter( 'storefront_product_thumbnail_columns', 'dk_single_gallery_columns_storefront', 99 );
function dk_single_gallery_columns_storefront() {
return 1;
}
/* --- END PHASE 1 --- */
/* --- PHASE 2 add CSS --- */
add_action('wp_head','dkAddVertGalleryCSS');
function dkAddVertGalleryCSS() {
echo '<style>
#media (min-width: 0px) {
/* Make image width smaller to make room to its right */
.single-product div.product .images .woocommerce-main-image, .flex-viewport {
width: 85%;
float: left;
}
/* Make Gallery smaller width and place it beside the image */
.single-product div.product .images .thumbnails, ol.flex-control-nav.flex-control-thumbs {
width: 15%;
float: left;
margin-top: 40px !important;
}
/* Style each Thumbnail with width and margins */
.single-product div.product .images .thumbnails a.zoom, ol.flex-control-nav.flex-control-thumbs a.zoom {
width: 90%;
float: none;
margin: 0 0 10% 10%;
}
/* Move the zoom tool to the left side to accommodate the gallery thumbs (otherwise it covers the first thumbnail */
.single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__trigger {
left: .875em !important;
}
}
</style>';
}
/* --- END PHASE 2 --- */

First, we need to make sure our Product Gallery has 1 image per row if we want to display it vertically (the default is 3 if I’m not wrong).
/**
* #snippet Change Gallery Columns # Single Product Page
* #how-to Watch tutorial # https://businessbloomer.com/?p=19055
* #sourcecode https://businessbloomer.com/?p=20518
* #author Rodolfo Melogli
* #testedwith WooCommerce 2.5.5
*/
add_filter ( 'woocommerce_product_thumbnails_columns', 'bbloomer_change_gallery_columns' );
function bbloomer_change_gallery_columns() {
return 1;
}
// ---------------------
// For Storefront theme:
add_filter ( 'storefront_product_thumbnail_columns', 'bbloomer_change_gallery_columns_storefront' );
function bbloomer_change_gallery_columns_storefront() {
return 1;
}
// ---------------------
CSS Snippet (Part 2 of 2): Edit the WooCommerce Product Gallery CSS
Second, we need to “move” the Product Gallery beside the image. This is pretty basic CSS you can place in your child theme’s stylesheet.
/**
* #snippet CSS to Move Gallery Columns # Single Product Page
* #sourcecode https://businessbloomer.com/?p=20518
* #author Rodolfo Melogli
* #testedwith WooCommerce 2.5.5, Storefront 1.6
*/
#media (min-width: 0px) {
/* Make image 75% width to make room to its right */
.single-product div.product .images .woocommerce-main-image {
width: 75%;
float: left;
}
/* Make Gallery 25% width and place it beside the image */
.single-product div.product .images .thumbnails {
width: 25%;
float: left;
}
/* Style each Thumbnail with width and margins */
.single-product div.product .images .thumbnails a.zoom {
width: 90%;
float: none;
margin: 0 0 10% 10%;
}
}
You can place PHP snippets at the bottom of your child theme functions.php file (and in case of CSS, this goes at the bottom of the style.css file) - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Related

how to use same html and css code, but changing only image url? (for not repeat the same code)

hope one of you can give me a “how to” hint.
I’m a newbie here and in building a website. I’ve written a website with “50 odd pages” for my photos. Photography is my passion, not website building. On each page 1 photo, is centered vertically, horizontally, bladibla, and a button for showing a full-screen copy of the photo. For that purpose, I use CSS overlay and a script to open and close.
As you’ll understand, on each page the same CSS stylesheet, except for the URL of the photo which is mentioned twice. In the head as part of the CSS overlay code and once more in the body for addressing the photo.
A snippet of the overlay code:
.overlay-content {
background-image: url("https://.../images/photo_0X.png");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
And in the body:
<img id="photo" src="https://.../images/photo_0X.png">
This works perfectly but for maintenance purposes, I would like to simplify the code of my pages and therefore create 1 (external) CSS file for all pages. Regularly I change background color, and fonts, and add pages/photos.
My question is as follows: Is it possible to generalize the “background-image: url” line of the overlay code? E.g. by adding an image id to the image line in the body. There’s just 1 photo on each page so I could give every photo the same img id. E.g. img id=”photo”. As above. In other words; would it be possible to refer in the overlay code to the image id in the body instead of repeating the full path to the photo? Referring to the image id is just an idea, every other suggestion is appreciated. P.S. I love simple solutions.
Thanks a lot, even if it’s just for reading this “long read” (-;
example here: https://jsfiddle.net/9sx3bjg7/
there isn't any need to create 50 pages by hand.
just create an array with all your images ["./myImg", "./anotherImg", "https://myImageLink"]
and create one HTML file
and change the URL parameter with the index of the image,
then get the index from the link and show the image on the index of the array
in javascript we change the --src CSS variable, and everything will work!
css var: https://developer.mozilla.org/en-US/docs/Web/CSS/var
why change the URL?
so if the user like an image
he can copy the link,
and maybe send it to another friend,
and the friend can see directly the image
without the need to see all the images first.
this means every time you click next (➡️) you refresh the page and have a new image (and now you solved the problem of more pages)
for example:
localhost:3000/?id=10
myUrl.com/?id=10
this technique is used also by google.com,
try for example do a search,
and the link will be changed to ?q=.
same concept also here for not making infinite pages.
how it work?
here the working example:
/* get img container */
let img = document.querySelector("#img-container");
/* get id from url */
/* if the user see the website for first time reset to 0 */
let id = getId();
changeImg();
/* button functionalities */
function next() {
id++;
window.location.search = `id=${id}`;
}
function prev() {
id--;
window.location.search = `id=${id}`;
}
/* id functionalities */
function getId() {
let result = []; // []
// details about location.search https://stackoverflow.com/a/26803253/17716837
let stringArray = location.search.replace("?", "").split("&"); // ["id=number", "another=string"]
stringArray.forEach((string) => {
result.push(string.split("="));
}); // [[id, number], [other, string], [another, string]
result = Object.fromEntries(result); // {id: number, another: string}
return result.id ?? 0; // number (or 0 if undefined)
}
function resetId() {
window.location.search = `id=0`;
}
/* change image functionalities */
function changeImg() {
/* if the user see all image, then we reset the id to 0 */
let choosedImg = imgArray[id] ? imgArray[id] : resetId();
/* changing a css variable */
img.style.setProperty("--src", `url(${choosedImg})`);
}
/* the most important part is here, the other also only css designs */
#container #img-container {
/* src get changed automatically by javascript */
background-image: var(--src);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 0.5rem;
}
* {
box-sizing: border-box;
}
body {
/* centering vertically and horizontally */
display: grid;
place-items: center;
height: 100vh;
margin: 0;
}
/* container responsive */
#container {
width: 80vmin;
height: 80vmin;
}
#container {
padding: 1rem;
border-radius: 0.5rem;
border: 1px solid #ccc;
}
#container {
/* make image bigger, buttons smaller */
display: grid;
grid-template-rows: 1fr auto;
gap: 1rem;
}
/* button flexbox */
#btn-container {
display: flex;
gap: 1rem;
}
/* buttons responsive width */
#btn-container button {
flex: 1;
}
<div id="container">
<div id="img-container" style="--src: https://picsum.photos/500">
<!-- here it will be a image -->
</div>
<div id="btn-container">
<button title="previus" onclick="prev();">⬅️</button>
<button title="next" onclick="next()">➡️</button>
</div>
</div>
<!-- just change the array :) -->
<script>
/* here put all your img urls */
let imgArray = [
"https://i.stack.imgur.com/ZtQFV.jpg", /* 0 */
"https://i.stack.imgur.com/1zsuD.jpg", /* 1 */
"https://i.stack.imgur.com/gONSm.jpg", /* 2 */
"https://i.stack.imgur.com/pmIwb.jpg", /* 3 */
"https://i.stack.imgur.com/7qow3.jpg", /* 4 */
"https://i.stack.imgur.com/JPr4x.jpg", /* ... until 50+ */
];
</script>
<!-- make sure to import the script at the end, or after the array in html -->
<script src="script.js"></script>
responsive:
also is responsive because we using vmin
vmin means CSS will get the smaller dimension on screen (height or width) and then divide it by 100.
vertically responsive:
horizontally responsive:

CSS to get rid of white space in Wordpress Twenty Nineteen theme?

My page at www.risingtidescoffeecompany.com/home/ has a white space below the navigation bar/above the large slider.
I am trying to figure out how to remove that white space, making the slider below the masthead flush with the navigation bar. I have already hidden the entry title using CSS, and I have tried several suggestions I found on Google, though nothing worked.
From the inspector it looks like your problem is the top margin imposed by the following css, (line 5196)
/* Blocks */
/* !Block styles */
.entry .entry-content > *,
.entry .entry-summary > * {
margin: 32px 0;
max-width: 100%;
}
And it reapears in the media query, (line 5217)
#media only screen and (min-width: 768px) {
.entry .entry-content > *,
.entry .entry-summary > * {
margin: 32px 0;
}
}
It is in the theme you mentioned themes/twentynineteen/style.css?ver=1.4
If both css lines are deactivated the gap goes away, tested in chrome.

How to remove white space between images on wordpress mobile version?

I have been searching for a while trying different methods to try and remove white space between my images on the home screen on my mobile version. It only occurs on my mobile version. My url for the site is below:
https://athleteperks.co.uk
I also have a thin small white gap between two images on my home screen which wold also be great to remove. It would be great if someone could help.
thanks
If you are referring to the bottom 5 images before the footer there is padding that needs to be removed on mobile state 767 like so:
.fw-row .blog-grid-items {
padding:0;
}
.blog-grid-items .blog-item.col-sm-sf-5 {
padding:0;
}
Adding the above CSS makes the last 5 images full width on mobile and eliminates white space.
Also removing the below CSS eliminates the small 1px gap between the two images on your home screen:
.row:not(.fw-row) .spb_swift-slider .swift-slider {
margin-left: 0;
}
Edited Answer
The below CSS needs to be added to your stylesheet in order to remove the white space from the images on mobile:
.spb_text_column, .spb_content_element {
margin-bottom: 0;
}
/* Mobile media query */
#media (max-width: 767px) {
.swift-slider-outer {
height: auto !important;
}
}
In order for the above media query to work you must have in your head file the following:
<meta name="viewport" content="width=device-width, initial-scale=1">
here is the code if you want to rid out the space in between the 5 images in the same row:
.col-sm-sf-5 {
width: 25%;
padding: 0px;
float: left;
}
.row:not(.fw-row) .spb_swift-slider .swift-slider {
margin-left: 0px;
}
.row {
margin-left: -15px;
margin-right: -15px;
}
.blog-grid-items .blog-item {
margin: 0 0 0px;
height: 330px;
padding-top: 0;
}
If you want to modify the design only for a mobile version, with resolution 1024 px, add this code and put inside this code your new classes above.
#media only screen and (max-width : 1024px) {
.classname {
/* other styles here */
}
}

WordPress - Reduce vertical space between main menu and Slider

I have created a wordpress single theme, but I am getting confuse with CSS code, where CSS rules should change the display to make menu and image slider revolution look closer.
I would like to reduce the space between the main navigation menu and my revolution slider
This is my website url: http://www.warungrempong.com/
I am trying to use this CSS code:
.admin-bar .nav-container {
min-height: 0;
}
But it's not working as desired and only work when I am using it on my browser dev tools.
When I try to change in my website, nothing happen.
How can I solve this issue?
Thanks.
In the style.css file of your active child theme (or theme), You should add this:
.nav-container {
min-height: inherit !important;
}
When looking at the generated source code of your home page, it seems that your theme is embedding some CSS rules in the html document, as you have this (on line 41 of that source code):
<style id='ebor-style-inline-css' type='text/css'>
nav .pb80 {
padding-bottom: 0px;
padding-top:0px;
}
.pt120 {
padding-top: 0px;
}
.nav-container { /* ==========================> HERE ONE TIME */
min-height: 0;
}
.logo { max-height: 300px; }
.nav-container { /* ======================> HERE ANOTHER TIME
As this is the last instance, it get the priority on first one! */
min-height: 491px;
}
.admin-bar .nav-container {
min-height: 523px;
}
#media all and (max-width: 767px){
.nav-container {
min-height: 366px;
}
.admin-bar .nav-container {
min-height: 398px;
}
}
</style>
So may be you have add this CCS rules yourself somewhere in your theme settings. The best thing, should be to remove that 2 repetitive CSS rules, and your issue should get solved without any need…

Change width of sidebar and content in Wordpress products page

Hi dear developers and designers,
I've got a problem in editing my wordpress woocommerce based template.
I use the woocommerce theme named Neighborhood from ThemeForest in my website.
all I want to know is how to edit the width of Sidebar & Content ,( Shop Products or Post)
the theme is full width and fully responsive, so the percentage of showing would be great not a fixed pixel.
percentage of thor ratio or whatever
for example this page of my website http://aryagostarafzar.com/shop/digital-painting-pack2
you see the sidebar in the left which is about 1/3of whole width.
i could change the sidebar percentage of showing by putting this code is css :
.left-sidebar {
width:20%;
}
but the content does not automatically fit the smaller sidebar and the extra space remains free and not used by content nor sidebar.
please give me a short css code to set both.
thanks
Looks like the site is using an old version of the Bootstrap grid. The sidebar width is being determined by the ".span4" class on the tag. You'd need to increase or decrease that span class to make it larger smaller.
That will also increase or decrease the body width size. The spans must add up to 12. i.e
span4 and span8
You can ready more on it here: http://getbootstrap.com/2.3.2/scaffolding.html
Here is my bootstrap codes in styles.css
I don't find " .span4 "
other .span are available but not defined by percentage, is defined by pixel
how to edit them my friend
* #Custom Bootstrap Classes
================================================== Support for columns width sidebars
==================================================
.span-third {
width: 193px;
}
.span-twothirds {
width: 407px;
}
.span-bs-quarter {
width: 100px;
}
.span-bs-threequarter {
width: 340px;
}
#media only screen and (min-width: 1200px) {
.span-third {
width: 236px;
}
.span-twothirds {
width: 504px;
}
.span-bs-quarter {
width: 120px;
}
.span-bs-threequarter {
width: 420px;
}
}
#media only screen and (max-width: 979px) and (min-width: 768px) {
.span-third {
width: 145px;
}
.span-twothirds {
width: 310px;
}
.span-bs-quarter, .span-bs-threequarter {
width: 342px;
}
}
#media only screen and (max-width: 979px) {
.span-third {
width: 100%;
}
.span-twothirds {
width: 100%;
}
.span-bs-quarter {
width: 100%;
}
.span-bs-threequarter {
width: 100%;
}
}

Resources