Last active
March 14, 2019 22:49
-
-
Save NovaYear/6ad15fc3b7dda21f78809ef60a5097cc to your computer and use it in GitHub Desktop.
in one container amp lightbox image gallery simple idea example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html ⚡> | |
<head> | |
<meta charset="utf-8"> | |
<script async src="https://cdn.ampproject.org/v0.js"></script> | |
<script async custom-element="amp-lightbox" src="https://cdn.ampproject.org/v0/amp-lightbox-0.1.js"></script> | |
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | |
<link rel="canonical" href="https://ampbyexample.com/components/amp-lightbox/"> | |
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript> | |
<style amp-custom> | |
amp-img.cropped img { | |
object-fit: cover; | |
} | |
amp-lightbox .lightbox { | |
background: #333; | |
width: 100%; | |
height: 100%; | |
display: flex; | |
justify-content: center; | |
flex-direction: column; | |
} | |
amp-img.gals { | |
display: none; | |
} | |
amp-img.gals.show { | |
display: block; | |
} | |
.lbx-button-close { | |
position: absolute; | |
cursor: pointer; | |
width: 24px; | |
height: 24px; | |
padding: 16px; | |
box-sizing: content-box; | |
top: 0; | |
right: 0; | |
} | |
.lbx-icon { | |
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M18.295 5.705a.997.997 0 0 0-1.41 0L12 10.59 7.115 5.705a.997.997 0 1 0-1.41 1.41L10.59 12l-4.885 4.885a.997.997 0 0 0 1.41 1.41L12 13.41l4.885 4.885a.997.997 0 0 0 1.41-1.41L13.41 12l4.885-4.885a.997.997 0 0 0 0-1.41z' fill='%23fff' fill-rule='nonzero'/%3E%3C/svg%3E"); | |
width: 100%; | |
height: 100%; | |
display: block; | |
background-repeat: no-repeat; | |
background-position: 50%; | |
} | |
</style> | |
</head> | |
<body> | |
<amp-img class="cropped" on="tap:img-lightbox" role="button" tabindex="0" src="https://unsplash.it/300/200" width="200" height="200"></amp-img> | |
<p>if you have another development idea, please share in comments.</p> | |
<amp-lightbox id="img-lightbox" layout="nodisplay"> | |
<div role="button" class="lbx-button-close" aria-label="Close" on="tap:img-lightbox.close"> | |
<span class="lbx-icon"></span> | |
</div> | |
<div class="lightbox" on="tap:img-lightbox.close" role="button" tabindex="0"> | |
<div> | |
<amp-img id="img1" class="gals show" src="https://unsplash.it/300/200" layout="responsive" width="300" height="200" on="tap:img1.toggleClass(class=show, force=false),img2.toggleClass(class=show, force=true)"></amp-img> | |
<amp-img id="img2" class="gals" src="https://unsplash.it/300/204" layout="responsive" width="300" height="200" on="tap:img2.toggleClass(class=show, force=false),img3.toggleClass(class=show, force=true)"></amp-img> | |
<amp-img id="img3" class="gals" src="https://unsplash.it/300/205" layout="responsive" width="300" height="200" on="tap:img3.toggleClass(class=show, force=false),img1.toggleClass(class=show, force=true)"></amp-img> | |
</div> | |
</div> | |
</amp-lightbox> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment