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
Related
.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'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>
I made a row with 100 columns and each should be as small as possible. But as you can see below the 13th column is acting odd.
all the images and columns are generated using the same code so each height should be the same. I do know the 12 column rule for bootstrap, but I'm okay with it wrapping around at 12 or 40 I dont have a width rule in the application. Also if anyone can help the images are responsive but the column count is not if i shrink the window it goes straight to one column per row instead of say 11 and then 10 and so forth and so on.
<div class="form-horizontal container" id="ActualHallOfLights">
<div class="row">
<div class="thumbnail col-sm-1"> 1:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 2:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 3:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 4:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 5:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 6:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 7:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 8:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 9:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 10:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 11:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 12:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 13:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 14:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 15:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
</div>
</div>
Your images probably vary slightly in height, possibly due to sub-pixel rounding. For this reason, the column elements that contain them also vary. This disrupts float behavior.
One common solution is to set a minimum height on the columns (or the images). Another is to set your images as backgrounds instead, with a size of cover, and use the responsive element to set heights. You could just be sure your images all have exactly the same original size, but that's a fragile approach. Even one faulty image breaks the layout.
In any event, they all need to be the same height.
removed the image tag and added these styles to the div containing the image
.bgLightOn {
background-image: url('/Images/LightBulbOn.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: bottom;
width: 70px;
height: 110px;
}
As i see in the image, LightBulbOff and LightBulbOn image have slightly difference in height. The height of both images must have same size. Or you may use clearfix class after each 12th image.
I have designed a grid layout using divs. As you can see below. However I need to center these horizontally in the middle of the web browser. Could somebody please show me how? Everything I have tried seems to align all of the divs centrally as if they are in one column over the top of each other.
Thanks in advance.
HTML
<div class="row">
<div class="col">
<div class="trigger vertical img1">
<div tabindex="0" class="maincontent static"><div class="slider">
<img src="slide1.png" width="200" />
<img src="slide2.png" width="200" />
<img src="slide3.png" width="200" />
<img src="slide4.png" height="200"/>
</div></div>
</div>
</div>
<div class="col">
<div class="trigger img1">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div></div>
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
</div>
<!-- </div>
<div class="row">-->
<div class="col">
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img4"><img src="STEP1.jpg" width="200"/><p>Text Here 4<p></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img5"><img src="STEP3.jpg" width="200"/><p>Text Here 5<p></div>
</div>
</div>
<div class="col">
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img6"><img src="STEP2.jpg" width="200"/><p>Text Here 6<p></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img7"><img src="STEP4.jpg" width="200"/><p>Text Here 7<p></div>
</div>
</div>
</div>
<div class="row">
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger large">
<div tabindex="0" class="maincontent staticlarge"><div class="slider">
<img src="slide1.png" height="200" width="400" />
<img src="slide2.png" height="200" width="400" />
<img src="slide3.png" height="200" width="400" />
<img src="slide4.png" height="200" width="400" />
</div></div>
</div>
</div>
<div class="row">
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent staticlarge">
<iframe align="center" src="clock2.php" width="300px" height="200px" scrolling="no" frameBorder="0" style="margin-left:5px;"></iframe></div></div>
CSS
<style type="text/css">
.trigger {
width:200px;
height:200px;
}
.trigger.large {
width: 400px;
}
.trigger.vertical {
height: 400px;
}
.trigger.vertical * {
height: 400px;
}
.hover-img, .hover-img.hover_effect {
position: relative;
width: 200px;
height: 200px;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
-webkit-transform-style: preserve-3d;
text-align: center;
font-size: 0;
-webkit-user-select: none;
-webkit-touch-callout: none;
border-style: solid;
border-width: 1px;
border-color: #CCCCB2;
border-radius: 5px;
}
.static {
position: relative;
width: 200px;
height: 200px;
text-align: center;
font-size: 0;
border-style: solid;
border-width: 1px;
border-color: #CCCCB2;
border-radius: 5px;
}
.staticlarge {
position: relative;
width: 400px;
height: 200px;
text-align: center;
font-size: 0;
border-style: solid;
border-width: 1px;
border-color: #CCCCB2;
border-radius: 5px;
}
.trigger.large .hover-img, .trigger.large .hover-img.hover_effect {
width: 400px;
}
.trigger:hover > .hover-img {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
font-size: 14px;
color: #FFF;
}
.trigger:hover > .hover-img.img4 {
background-color: #f47878;
}
.trigger:hover > .hover-img.img5 {
background-color: #f6c447;
}
.trigger:hover > .hover-img.img6 {
background-color: #92cf96;
}
.trigger:hover > .hover-img.img7 {
background-color: #f47878;
}
.trigger:hover > .hover-img.img12 {
background-color: #92cf96;
}
.trigger:hover .hover-img img {
display: none;
}
#container {
width:960px;
margin: 0 auto;
}
.row {
display: flex;
}
.col {
display:inline-block;
}
.trigger.large .hover-img, .trigger.large .hover-img.hover_effect {
width: 400px;
}
#apDiv1 {
position: absolute;
width: 100px;
height: 200px;
z-index: 1;
background-color: #999999;
}
.trigger:hover p {
display:block;
transform:scaleX(-1)
}
Use a div to wrap your HTML like below <div class="bodyCont">
<div class="bodyCont">
<div class="row">
<div class="col">
<div class="trigger vertical img1">
<div tabindex="0" class="maincontent static"><div class="slider">
<img src="slide1.png" width="200" />
<img src="slide2.png" width="200" />
<img src="slide3.png" width="200" />
<img src="slide4.png" height="200"/>
</div></div>
</div>
</div>
<div class="col">
<div class="trigger img1">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div></div>
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
</div>
<!-- </div>
<div class="row">-->
<div class="col">
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img4"><img src="STEP1.jpg" width="200"/><p>Text Here 4<p></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img5"><img src="STEP3.jpg" width="200"/><p>Text Here 5<p></div>
</div>
</div>
<div class="col">
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img6"><img src="STEP2.jpg" width="200"/><p>Text Here 6<p></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent hover-img img7"><img src="STEP4.jpg" width="200"/><p>Text Here 7<p></div>
</div>
</div>
</div>
<div class="row">
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger large">
<div tabindex="0" class="maincontent staticlarge"><div class="slider">
<img src="slide1.png" height="200" width="400" />
<img src="slide2.png" height="200" width="400" />
<img src="slide3.png" height="200" width="400" />
<img src="slide4.png" height="200" width="400" />
</div></div>
</div>
</div>
<div class="row">
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent static"><div class="slider2">
<img src="slide1.png" height="200" width="200" />
<img src="slide2.png" height="200" width="200" />
<img src="slide3.png" height="200" width="200" />
<img src="slide4.png" height="200" width="200" />
</div></div>
</div>
<div class="trigger">
<div tabindex="0" class="maincontent staticlarge">
<iframe align="center" src="clock2.php" width="300px" height="200px" scrolling="no" frameBorder="0" style="margin-left:5px;"></iframe></div></div>
</div>
Then since you are having fixed width for all these items it becomes easy calculate the width for all total width=800px.
Apply it to the outercontainer and margin:0 auto; will do the trick
CSS
.bodyCont{
width :800px;
margin:0px auto;
}
DEMO
simply give the first div (the one before class="row") a class (i.e. wrapper) and insert following css to center the complete wrapper content into the middle of the screen:
.wrapper {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
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