I'm trying to wrap() the .gallery-items with the text() that is an url from the .gallery-caption. My problem is that all the urls are fetched and inserted into the a href"=https://s.
What would be the proper way to make it work correctly? Thank you in advance.
Below is my attempt:
$(".gallery-item").wrap($("<a/>").attr("href", "http://"+$(".gallery-caption").text().trim()));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/areklam.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-39">
</div>
<figcaption class="wp-caption-text gallery-caption" id="gallery-1-39">
www.areklam.hu
</figcaption></figure><figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/arkad.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-40">
</div>
<figcaption class="wp-caption-text gallery-caption" id="gallery-1-40">
www.arkadbudapest.hu
</figcaption></figure><figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/besttv.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-41">
</div>
<figcaption class="wp-caption-text gallery-caption" id="gallery-1-41">
www.besttv.hu
</figcaption></figure><figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/bosch.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-42">
</div>
I also tried to implement the $(this)... but I might have it used wrongly.
You can simply use each loop and then inside this loop use this which will refer to current element which is iterated .
Demo Code :
$(".gallery-item").each(function() {
$(this).wrap($("<a/>").attr("href", "http://" + $(".gallery-caption", this).text().trim()));
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/areklam.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-39">
</div>
<figcaption class="wp-caption-text gallery-caption" id="gallery-1-39">
www.areklam.hu
</figcaption>
</figure>
<figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/arkad.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-40">
</div>
<figcaption class="wp-caption-text gallery-caption" id="gallery-1-40">
www.arkadbudapest.hu
</figcaption>
</figure>
<figure class="gallery-item">
<div class="gallery-icon landscape">
<img width="200" height="74" src="https://webhelytervezo.hu/wp-content/uploads/2022/01/besttv.jpg" class="attachment-full size-full" alt="" loading="lazy" aria-describedby="gallery-1-41">
</div>
<figcaption class="wp-caption-text gallery-caption" id="gallery-1-41">
www.besttv.hu
</figcaption>
</figure>
Related
I have created a grid layout for desktop but, for mobile, it is different.
Below is the photo of desktop version
I created this layout using the following code:
<div class="grid grid-flow-col grid-rows-2 gap-1 ml-auto justify-center mt-2.5">
<img src="{{view url='images/icons/ic_mastercard.svg'}}" width="44" height="30" alt="mastercard" loading="lazy">
<div class="w-[44px] h-[30px] hidden md:block"></div>
<img src="{{view url='images/icons/ic_maestro-white-bg.svg'}}" width="44" height="30" alt="mastercard" loading="lazy">
<img src="{{view url='images/icons/ic_gb.svg'}}" width="44" height="30" alt="GB" loading="lazy">
<img src="{{view url='images/icons/ic_visa.svg'}}" width="44" height="30" alt="visa" loading="lazy">
<img src="{{view url='images/icons/ic_bancontact-white-bg.svg'}}" width="44" height="30" alt="Bancontact" loading="lazy">
<img src="{{view url='images/icons/ic_american-ex.svg'}}" width="44" height="30" alt="american exprerss" loading="lazy">
<img src="{{view url='images/icons/ic_eps-white-bg.svg'}}" width="44" height="30" alt="EPS" loading="lazy">
<img src="{{view url='images/icons/ic_paypal.svg'}}" width="44" height="30" alt="paypal" loading="lazy">
<img src="{{view url='images/icons/ic_multibanco-white-bg.svg'}}" width="44" height="30" alt="Multibanco" loading="lazy">
<img src="{{view url='images/icons/ic_klarna-pink-bg.svg'}}" width="44" height="30" alt="klarna" loading="lazy">
<img src="{{view url='images/icons/ic_giropay-white-bg.svg'}}" width="44" height="30" alt="Giropay" loading="lazy">
<img src="{{view url='images/icons/ic_gpay-white-bg.svg'}}" width="44" height="30" alt="google pay" loading="lazy">
<img src="{{view url='images/icons/ic_alipay-white-bg.svg'}}" width="44" height="30" alt="Alipay" loading="lazy">
<img src="{{view url='images/icons/ic_applepay-white-bg.svg'}}" width="44" height="30" alt="apple pay" loading="lazy">
<img src="{{view url='images/icons/sofort.svg'}}" width="44" height="30" alt="Sofort" loading="lazy">
</div>
Now, the issues is, when I switch to mobile, the layout stays the same but, instead, the layout on mobile should be like below photo
How can I create the layout for mobile like shown in this photo using grid ?
You have to replace grid layout with flex and flex-wrap property for your desired behaviour.
Try the following code:
<div class="mx-auto mt-2.5 flex w-96 flex-wrap items-center justify-center gap-1">
<img src="{{view url='images/icons/ic_mastercard.svg'}}" width="44" height="30" alt="mastercard" loading="lazy" />
<div class="hidden h-[30px] w-[44px] md:block"></div>
<img src="{{view url='images/icons/ic_maestro-white-bg.svg'}}" width="44" height="30" alt="mastercard" loading="lazy" />
<img src="{{view url='images/icons/ic_gb.svg'}}" width="44" height="30" alt="GB" loading="lazy" />
<img src="{{view url='images/icons/ic_visa.svg'}}" width="44" height="30" alt="visa" loading="lazy" />
<img src="{{view url='images/icons/ic_bancontact-white-bg.svg'}}" width="44" height="30" alt="Bancontact" loading="lazy" />
<img src="{{view url='images/icons/ic_american-ex.svg'}}" width="44" height="30" alt="american exprerss" loading="lazy" />
<img src="{{view url='images/icons/ic_eps-white-bg.svg'}}" width="44" height="30" alt="EPS" loading="lazy" />
<img src="{{view url='images/icons/ic_paypal.svg'}}" width="44" height="30" alt="paypal" loading="lazy" />
<img src="{{view url='images/icons/ic_multibanco-white-bg.svg'}}" width="44" height="30" alt="Multibanco" loading="lazy" />
<img src="{{view url='images/icons/ic_klarna-pink-bg.svg'}}" width="44" height="30" alt="klarna" loading="lazy" />
<img src="{{view url='images/icons/ic_giropay-white-bg.svg'}}" width="44" height="30" alt="Giropay" loading="lazy" />
<img src="{{view url='images/icons/ic_gpay-white-bg.svg'}}" width="44" height="30" alt="google pay" loading="lazy" />
<img src="{{view url='images/icons/ic_alipay-white-bg.svg'}}" width="44" height="30" alt="Alipay" loading="lazy" />
<img src="{{view url='images/icons/ic_applepay-white-bg.svg'}}" width="44" height="30" alt="apple pay" loading="lazy" />
<img src="{{view url='images/icons/sofort.svg'}}" width="44" height="30" alt="Sofort" loading="lazy" />
</div>
You can also use grid, but in the below code, the grid will always display in 5x3 matrix (since we have 15 images).
<script src="https://cdn.tailwindcss.com"></script>
<div class="grid grid-flow-col grid-rows-3 sm:grid-rows-2 gap-1 ml-auto justify-center mt-2.5">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="mastercard" loading="lazy">
<div class="w-[44px] h-[30px] hidden sm:block"></div>
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="mastercard" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="GB" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="visa" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="Bancontact" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="american exprerss" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="EPS" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="paypal" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="Multibanco" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="klarna" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="Giropay" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="google pay" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="Alipay" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="apple pay" loading="lazy">
<img src="https://dummyimage.com/720x400" width="44" height="30" alt="Sofort" loading="lazy" class="">
</div>
Tailwind Play link here
.gallery {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1.6rem;
padding: 1.6rem;
overflow: hidden;
height: fit-content;
}
.gallery-item {
overflow: hidden;
}
.gallery-item img {
display: block;
width: 100%;
max-height: 100%;
object-fit: cover;
transition: all 0.4s;
}
This is the CSS Styling, I do not know what I set wrong. If I try reducing the image width, it leaves empty container space
<div class="gallery">
<figure class="gallery-item">
<img
src="img/gallery/gallery-1.jpg"
alt="Photo of beautifully arranged food"
/>
<!-- <figcaption>Caption</figcaption> -->
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-2.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-3.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-4.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-5.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-6.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-7.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-8.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-9.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-10.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-11.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-12.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
</div>
This is the HTML Code although I am sure the code is correct
<!-- begin snippet: js hide: false console: true babel: false -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="description"
content="Omnifood is an AI-powered food subscription that will make you eat healthy again, 365 days per year. It's tailored to your personal taste and nutritional needs."
/>
<!-- Always include this line of code!!!!! -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght#300&family=Raleway:wght#200;400&family=Rubik:wght#400;500;600;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/general.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/queries.css" />
<!-- Titles usually come with a dash, |, colon or another symbol -->
<title>Omnifood — Never cook again</title>
</head>
<body>
<section class="section-testimonials" id="testimonials">
<div class="testimonials-container">
<span class="sub-heading">Testimonials</span>
<h2 class="heading-secondary font-reduce">
Once you try it, you can't go back
</h2>
<div class="testimonials">
<figure class="testimonial">
<img
class="testimonial-img"
src="img/customers/dave.jpg"
alt="Dave Bryson"
/>
<blockquote class="testimonial-text">
Inexpensive, healthy and great-tasting meals, without even
having to order manually! It feels truly magical.
</blockquote>
<p class="testimonial-name">— Dave Bryson</p>
</figure>
<figure class="testimonial">
<img
class="testimonial-img"
src="img/customers/ben.jpg"
alt="Ben Hadley"
/>
<blockquote class="testimonial-text">
The AI algorithm is crazy good, it chooses the right meals for
me everytime. It's amazing not to worry about food anymore!
</blockquote>
<p class="testimonial-name">— Ben Hadley</p>
</figure>
<figure class="testimonial">
<img
class="testimonial-img"
src="img/customers/steve.jpg"
alt="Steve Miller"
/>
<blockquote class="testimonial-text">
Omnifood is a life saver! I just started a company, so there's
no time for cooking. I couldn't live without my daily meals now!
</blockquote>
<p class="testimonial-name">— Steve Miller</p>
</figure>
<figure class="testimonial">
<img
class="testimonial-img"
src="img/customers/hannah.jpg"
alt="Hannah Smith"
/>
<blockquote class="testimonial-text">
I got Omnifood for the whole family, and it frees up so much
time! Plus, everything is organic and vegan and without plastic.
</blockquote>
<p class="testimonial-name">— Hannah Smith</p>
</figure>
</div>
</div>
<div class="gallery">
<figure class="gallery-item">
<img
src="img/gallery/gallery-1.jpg"
alt="Photo of beautifully arranged food"
/>
<!-- <figcaption>Caption</figcaption> -->
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-2.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-3.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-4.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-5.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-6.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-7.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-8.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-9.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-10.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-11.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-12.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
</div>
</section>
<script
type="module"
src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.esm.js"
></script>
<script
nomodule
src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.js"
></script>
<script src="https://unpkg.com/smoothscroll-polyfill#0.4.4/dist/smoothscroll.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>
<div class="gallery">
<figure class="gallery-item">
<img
src="img/gallery/gallery-1.jpg"
alt="Photo of beautifully arranged food"
/>
<!-- <figcaption>Caption</figcaption> -->
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-2.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-3.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-4.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-5.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-6.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-7.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-8.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-9.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-10.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-11.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
<figure class="gallery-item">
<img
src="img/gallery/gallery-12.jpg"
alt="Photo of beautifully arranged food"
/>
</figure>
</div>
</section>
</body>
</html>
I have the below code in Bootstrap that display an image:
<div class="work">
<img class="anim" src="1.png" alt="Text1">
<img class="anim" src="2.jpeg" alt="Text2">
<img class="anim" src="3.jpeg" alt="Text3">
<img class="anim" src="4.jpeg" alt="Text4">
</div>
The result looks like this:
How can I add some heading/title to each picture in order to describe the purpose of each one?
Try this code with Bootstrap grid system and using h3 to insert title of image
<div class="row">
<div class="col-sm-6">
<h3>Text</h3>
<img class="anim" src="1.png" alt="Text1">
</div>
<div class="col-sm-6">
<h3>Text</h3>`
<img class="anim" src="2.png" alt="Text1">
</div>
<div class="col-sm-6">
<h3>Text</h3>
<img class="anim" src="3.png" alt="Text1">
</div>
<div class="col-sm-6">
<h3>Text</h3>
<img class="anim" src="4.png" alt="Text1">
</div>
</div>
You can use the figure element for this which Bootstrap has styling for, e.g
<div class="work">
<figure class="figure">
<figcaption class="figure-caption">Image 1</figcaption>
<img class="anim figure-img" src="1.png" alt="Text1">
</figure>
<figure class="figure">
<figcaption class="figure-caption">Image 2</figcaption>
<img class="anim figure-img" src="2.png" alt="Text2">
</figure>
<figure class="figure">
<figcaption class="figure-caption">Image 3</figcaption>
<img class="anim figure-img" src="3.png" alt="Text3">
</figure>
<figure class="figure">
<figcaption class="figure-caption">Image 4</figcaption>
<img class="anim figure-img" src="4.png" alt="Text4">
</figure>
</div>
This question already has answers here:
Center the content inside a column in Bootstrap
(7 answers)
Closed 5 years ago.
Here is my code sample. in full-width of the browser everything looks fine. But when I resize it, the images (cards) are more towards the left side (not centered).
How can I fix this?
HTML code:
<div class="container-fluid">
<div class="row ">
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
</div>
</div>
Since I'm using Bootstrap v4, it should automatically adjust according to the page. But here is what I experience...
See the image
You can try using a spacer class on the image when on smaller screens mx-sm-auto, for more info on these see here: https://v4-alpha.getbootstrap.com/utilities/spacing/
Apply display: inline-block; to the img tag then apply text-align: center; to the parent;
In your code, you have applied display: block; to the image tag. Where now image act as a blocked element. That's why your image is not aligned in the center.
I have applied text-align: center; for imghvr-fold-up, because I can handle the caption and images in a single point.
Output:
//CSS
.img-thumbnail {
display: inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/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">
<div class="row ">
<div class="col-md-2 text-center">
<figure class="imghvr-fold-up">
<figcaption class="">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up text-center">
<figcaption class="">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up text-center">
<figcaption>
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up text-center">
<figcaption>
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up text-center">
<figcaption>
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up text-center">
<figcaption>
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
</div>
</div>
Demo at codepen.
Add margin:auto and display: block to image to center it
Fiddle
.img-thumbnail{margin:auto;display:block}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row ">
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
<div class="col-md-2">
<figure class="imghvr-fold-up">
<figcaption class="text-center">
Hello
</figcaption>
<img src="http://via.placeholder.com/200x200" class="img-thumbnail" alt="Cinque Terre">
</figure>
</div>
</div>
</div>
I am working on a site where it has to be somewhat dynamically resizable and has multi-layered "twinkling lights" in the background. In chrome and firefox performance is negligible as I fade in and out the objects in a semi-random pattern but under safari their mere presence causes everything else to chug.
An example is this :
<div class="light_layer">
<img class="lights" src="1.png" width="1400" alt="">
<img class="lights" src="2.png" width="1400" alt="">
<img class="lights" src="3.png" width="1400" alt="">
<img class="lights" src="4.png" width="1400" alt="">
<img class="lights" src="5.png" width="1400" alt="">
<img class="lights" src="6.png" width="1400" alt="">
<img class="lights" src="7.png" width="1400" alt="">
<img class="lights" src="8.png" width="1400" alt="">
<img class="lights" src="9.png" width="1400" alt="">
<img class="lights" src="10-blue.png" width="1400" alt="">
<img class="lights" src="10.png" width="1400" alt="">
<img class="lights" src="11.png" width="1400" alt="">
<img class="lights" src="12.png" width="1400" alt="">
<img class="lights" src="13.png" width="1400" alt="">
<img class="lights" src="14.png" width="1400" alt="">
<img class="lights" src="15.png" width="1400" alt="">
<img class="lights" src="16.png" width="1400" alt="">
<img class="lights" src="17.png" width="1400" alt="">
<img class="lights" src="18.png" width="1400" alt="">
<img class="lights" src="19.png" width="1400" alt="">
</div>
The css :
.light_layer {
position: absolute;
width: 100%;
height: 100%;
}
.light_layer img {
position: absolute;
width: 100%;
min-width: 1200px;
min-height: 677px;
}
At first I thought it was the fading that slowing things down but even when I stop all actions going on and just have the layers and goto mouseover a nav element there is serious slowdown. Delete the light layer and the slowdown is gone.
Paint calls in the safari inspector profiler are taking 750+ms. My question is how the hell can I reduce this performance chug while keeping their sizes to fit as they are if possible?
Thanks in advance