Mạng xã hội
Hoặc copy link
Dưới đây lầ code Gallery image JS, HTML, CSS dành cho mọi người tham khảo. Các bạn nhớ thay link img bằng link hình ảnh của bạn nhé.
<div class='brand-img'>
<ul class="brand-ul">
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-australia-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-canada-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-hungary-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-india-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-ireland-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-madagascar-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/wp-content/uploads/2023/09/icons8-portugal-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-united-kingd00.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
<li>
<div class='normal'>
<img decoding="async" src="https://phuongbacjsc.vn/uploads/2023/09/icons8-united-states-minor-outlying-islands-100.png" alt="">
</div>
<div class='info'>
<h3>Single-origin coffee whatever</h3>
<p>Williamsburg tofu polaroid, 90's Bushwick irony locavore ethnic meh messenger bag Truffaut jean shorts.</p>
</div>
</li>
</ul>
</div>
<script type="text/javascript">
const nodes = [].slice.call(document.querySelectorAll('li'), 0);
const directions = { 0: 'top', 1: 'right', 2: 'bottom', 3: 'left' };
const classNames = ['in', 'out'].map(p => Object.values(directions).map(d => `${p}-${d}`)).reduce((a, b) => a.concat(b));
const getDirectionKey = (ev, node) => {
const { width, height, top, left } = node.getBoundingClientRect();
const l = ev.pageX - (left + window.pageXOffset);
const t = ev.pageY - (top + window.pageYOffset);
const x = l - width / 2 * (width > height ? height / width : 1);
const y = t - height / 2 * (height > width ? width / height : 1);
return Math.round(Math.atan2(y, x) / 1.57079633 + 5) % 4;
};
class Item {
constructor(element) {
this.element = element;
this.element.addEventListener('mouseover', ev => this.update(ev, 'in'));
this.element.addEventListener('mouseout', ev => this.update(ev, 'out'));
}
update(ev, prefix) {
this.element.classList.remove(...classNames);
this.element.classList.add(`${prefix}-${directions[getDirectionKey(ev, this.element)]}`);
}}
nodes.forEach(node => new Item(node));
</script>.brand-ul > li {
perspective: 341px;
}
.info {
transform: rotate3d(1, 0, 0, 90deg);
width: 100%;
height: 100%;
padding: 20px;
position: absolute;
top: 0;
left: 0;
border-radius: 4px;
pointer-events: none;
background-color: #fe1f07;
}
.in-top .info {
transform-origin: 50% 0%;
-webkit-animation: in-top 300ms ease 0ms 1 forwards;
animation: in-top 300ms ease 0ms 1 forwards;
}
.in-right .info {
transform-origin: 100% 0%;
-webkit-animation: in-right 300ms ease 0ms 1 forwards;
animation: in-right 300ms ease 0ms 1 forwards;
}
.in-bottom .info {
transform-origin: 50% 100%;
-webkit-animation: in-bottom 300ms ease 0ms 1 forwards;
animation: in-bottom 300ms ease 0ms 1 forwards;
}
.in-left .info {
transform-origin: 0% 0%;
-webkit-animation: in-left 300ms ease 0ms 1 forwards;
animation: in-left 300ms ease 0ms 1 forwards;
}
.out-top .info {
transform-origin: 50% 0%;
-webkit-animation: out-top 300ms ease 0ms 1 forwards;
animation: out-top 300ms ease 0ms 1 forwards;
}
.out-right .info {
transform-origin: 100% 50%;
-webkit-animation: out-right 300ms ease 0ms 1 forwards;
animation: out-right 300ms ease 0ms 1 forwards;
}
.out-bottom .info {
transform-origin: 50% 100%;
-webkit-animation: out-bottom 300ms ease 0ms 1 forwards;
animation: out-bottom 300ms ease 0ms 1 forwards;
}
.out-left .info {
transform-origin: 0% 0%;
-webkit-animation: out-left 300ms ease 0ms 1 forwards;
animation: out-left 300ms ease 0ms 1 forwards;
}
@-webkit-keyframes in-top {
from {
transform: rotate3d(-1, 0, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@keyframes in-top {
from {
transform: rotate3d(-1, 0, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@-webkit-keyframes in-right {
from {
transform: rotate3d(0, -1, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@keyframes in-right {
from {
transform: rotate3d(0, -1, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@-webkit-keyframes in-bottom {
from {
transform: rotate3d(1, 0, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@keyframes in-bottom {
from {
transform: rotate3d(1, 0, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@-webkit-keyframes in-left {
from {
transform: rotate3d(0, 1, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@keyframes in-left {
from {
transform: rotate3d(0, 1, 0, 90deg);
}
to {
transform: rotate3d(0, 0, 0, 0deg);
}
}
@-webkit-keyframes out-top {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(-1, 0, 0, 104deg);
}
}
@keyframes out-top {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(-1, 0, 0, 104deg);
}
}
@-webkit-keyframes out-right {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(0, -1, 0, 104deg);
}
}
@keyframes out-right {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(0, -1, 0, 104deg);
}
}
@-webkit-keyframes out-bottom {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(1, 0, 0, 104deg);
}
}
@keyframes out-bottom {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(1, 0, 0, 104deg);
}
}
@-webkit-keyframes out-left {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(0, 1, 0, 104deg);
}
}
@keyframes out-left {
from {
transform: rotate3d(0, 0, 0, 0deg);
}
to {
transform: rotate3d(0, 1, 0, 104deg);
}
}
/* you can ignore this ones */
.brand-img > ul {
padding: 0;
margin: 0 0 50px;
}
.brand-img > ul:after {
content: "";
display: table;
clear: both;
}
.brand-ul > li {
position: relative;
float: left;
width: 170px;
height: 170px;
margin: 5px;
padding: 0;
list-style: none;
}
.brand-ul > li > .normal {
display: inline-block;
vertical-align: top;
text-decoration: none;
border-radius: 4px;
}
.brand-ul > li h3 {
margin: 0;
font-size: 16px;
color: rgba(255, 255, 255, 0.9);
}
.brand-ul > li p {
font-size: 12px;
line-height: 1.5;
color: rgba(255, 255, 255, 0.8);
}
.brand-ul > li .normal {
width: 100%;
height: 100%;
background-color: #ECF0F1;
color: rgba(52, 73, 94, 0.6);
box-shadow: inset 0 2px 20px #e6ebed;
text-align: center;
line-height: 160px;
}
.brand-ul > li .normal img {
pointer-events: none;
width: auto;
vertical-align: -webkit-baseline-middle !important;
}