Концепция карусели, управляемой мышью

Разработка Концепция карусели, управляемой мышью

Нет прав для скачивания
Концепция карусели, управляемой мышью.
Пишем код HTML:
HTML:
<div id="wrap">
  <a href="#" class="hb">
    <div class="c">
      <img src="https://source.unsplash.com/user/web_tiki/2000x1300" alt=""/>
      <div class="txt">
        <h1>Title here</h1>
        <p>Some longer text here thats wide enough to span on several lines.</p>
      </div>
    </div>
  </a>
  <div class="fullBg">
    <img src="https://source.unsplash.com/user/web_tiki/2000x1300" alt=""/>
  </div>
  <a href="#" class="hb">
    <div class="c">
      <img src="https://source.unsplash.com/user/web_tiki/2000x1301" alt=""/>
      <div class="txt">
        <h1>Title here</h1>
        <p>Some longer text here thats wide enough to span on several lines.</p>
      </div>
    </div>
  </a>
  <div class="fullBg">
    <img src="https://source.unsplash.com/user/web_tiki/2000x1301" alt=""/>
  </div>
  <a href="#" class="hb">
    <div class="c">
      <img src="https://source.unsplash.com/user/web_tiki/2000x1302" alt=""/>
      <div class="txt">
        <h1>Title here</h1>
        <p>Some longer text here thats wide enough to span on several lines.</p>
      </div>
    </div>
  </a>
  <div class="fullBg">
    <img src="https://source.unsplash.com/user/web_tiki/2000x1302" alt=""/>
  </div>
  <a href="#" class="hb">
    <div class="c">
      <img src="https://source.unsplash.com/user/web_tiki/2000x1303" alt=""/>
      <div class="txt">
        <h1>Title here</h1>
        <p>Some longer text here thats wide enough to span on several lines.</p>
      </div>
    </div>
  </a>
  <div class="fullBg">
    <img src="https://source.unsplash.com/user/web_tiki/2000x1303" alt=""/>
  </div>
</div>
Пишем стиль:
CSS:
*{margin:0;padding:0;}
a {color:inherit;text-decoration:none;}
body,html{
  overflow:hidden;
  height:100%;
  font-size:16px;
  font-family: 'Montserrat', sans-serif;
  background:#000;
  color:#fff;
}
#wrap{
  position:absolute;
  left:0; top:0;
  width:150%;
  height:100%;
  display:flex;
  align-items:stretch;
  margin:0 25%;
}
.hb {
  position:relative;
  width:25%;
  z-index:1;
  display:flex;
  align-items:center;
  z-index:2;
  trasnform:scale(.97);
}
.c{
  position:relative;
  display:block;
  max-width:90%;
}
.c img {
  position:relative;
  display:block;
  width:100%;
  height:auto;
  z-index:2;
}
.txt {
  position:absolute;
  top:100%; left:10%;
  width:80%;
  opacity:0;
  padding:1em 0 0 1em;
  border-left:1px solid;
  z-index:1;
  transform:scaleY(1) translateY(-50px);
  transition:transform .2s, opacity .5s;
}
h1 {
  font-size:1.2em;
  font-weight:700;
  text-transform:uppercase;
}
.hb:hover .txt {
  opacity:1;
  transform:scaleY(1) translateY(0);
}
.fullBg {
  position:fixed;top:0;left:0;width:100%;height:100%;
  opacity:0;
  transition:transform .5s, opacity .5s;
  transform:scale(1);
  z-index:1;
}
.fullBg img {
  width:100%;height:100%;
  object-fit:cover;object-position:center;
  opacity:.5;
}
.hb:hover + .fullBg {opacity:1;transform:scale(1.02);}
.credits {
  position:fixed;
  bottom:0;right:0;
  padding:1.5em;
  font-size:.8em;
  text-align:right;
  font-style:italic;
  opacity:.8;
  transition:opacity .2;
  z-index:3;
}
.credits:hover {
  text-decoration:underline;
  opacity:1;
}
Пишем jquery для динамики:
JavaScript:
$(document).ready(function(){
  var docWidth = $('body').width(),
      $wrap = $('#wrap'),
      $images = $('#wrap .hb'),
      slidesWidth = $wrap.width();
 
  $(window).on('resize', function(){
    docWidth = $('body').width();
    slidesWidth = $wrap.width();
  })
 
  $(document).mousemove(function(e) {
    var mouseX = e.pageX,
        offset = mouseX / docWidth * slidesWidth - mouseX / 2;
    
    $images.css({
      '-webkit-transform': 'translate3d(' + -offset + 'px,0,0)',
              'transform': 'translate3d(' + -offset + 'px,0,0)'
    });
  });
})
Смотрим результат:
dd6.gif
Автор
baltun
Скачиваний
0
Просмотры
592
Первый выпуск
Обновление
Рейтинг
0.00 звёзд Оценок: 0

Ещё ресурсы от baltun

  • [HAL] XenForo Resource Manager WEBP
    Авторские [HAL] XenForo Resource Manager WEBP
    Позволяет загружать вложения и иконки в Менеджере ресурсов в формате webp.
  • D.C Style - Link Proxy
    D.C Style - Link Proxy
    Дополнение зашифрует внешние ссылки в статье и создаст страницу перенаправления для этих ссылок.
  • [HAL] Portfolio
    Авторские [HAL] Portfolio
    Плагин позволяет разместить краткое портфолио.
  • D.C Style - Attachment view
    D.C Style - Attachment view
    Разрешить гостю просматривать определенные расширения прикрепленных файлов.
  • D.C Style - Thumbnail
    D.C Style - Thumbnail
    Позволяет пользователям включать изображение обложки и миниатюры для своих тем.
Похожие ресурсы
Назад
Верх Низ