css实现自适应图片黑色画廊相册效果代码

代码语言:html

所属分类:画廊相册

代码描述:css实现自适应图片黑色画廊相册效果代码

代码标签: css 自适应 图片 黑色 画廊 相册

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:200,400" rel="stylesheet">


  
  
<style>
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  height: 100%;
  overflow: hidden;
  color: #FFF;
  background-color: #121519;
  font-family: "Montserrat", "Roboto", "Droid Sans", "Helvetica Neue", sans-serif;
}

ul, ol {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

a {
  text-decoration: none;
}

p {
  margin: 1rem 0;
}

.app {
  display: grid;
  grid-template-rows: 4rem 1fr 4rem;
  grid-template-columns: 20% 1fr;
  height: 100vh;
}

.header,
.footer {
  font-size: 0.75rem;
  font-weight: 200;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #a0a0a0;
}

.header {
  display: flex;
  justify-content: space-between;
  grid-column: 1/-1;
  padding: 0 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.header__left, .header__right {
  display: flex;
  align-items: center;
}

.main {
  grid-column: 1/-1;
  padding: 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  perspective: 1px;
  -ms-scroll-snap-type: block proximity;
      scroll-snap-type: block proximity;
  -ms-scroll-snap-destination: 0% 100%;
      scroll-snap-destination: 0% 100%;
  -ms-scroll-snap-points-y: repeat(100%);
      scroll-snap-points-y: repeat(100%);
}
@media screen and (min-width: 1024px) {
  .main {
    grid-column: 2/-1;
  }
}

.footer {
  display: flex;
  align-items: center;
  grid-column: 1/-1;
  padding: 0 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.footer p {
  margin-right: 1rem;
}
.footer a {
  color: #FFF;
}
.footer a:hover, .footer a:focus {
  text-decoration: underline;
}
.footer__more {
  display: none;
  margin-left: auto;
  margin-right: 0;
}
@media screen and (min-width: 768px) {
  .footer__more {
    display: block;
  }
}

.nav {
  display: none;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav__item:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.nav__link {
  display: block;
  color: #FFF;
  font-weight: 200;
}
.nav__link:hover, .nav__link:focus {
  background-color: rgba(255, 255, 255, 0.035);
}
@media screen and (min-width: 1024px) {
  .nav {
    display: block;
    grid-column: 1/2;
  }
}

.section {
  min-height: 500px;
  min-height: calc(100vh - 4rem - 4rem);
  padding-top: 300px;
  margin-bottom: 250px;
  position: relative;
  transform-style: preserve-3d;
  scroll-snap-align: start;
}
.section__header {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  height: 500px;
  padding: 2rem;
  border-radius: 0.5rem;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.25);
}
.section__header::after {
  content: "";
  display: block;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
}
.section__title {
  font-size: 3.5rem;
  font-weight: 200;
  margin-bottom: 0.5rem;
  line-height: 1;
}
.section__subtitle {
  font-size: 1.5rem;
}
.section__controls {
  display: flex;
  align-items: center;
  position: absolute;
  padding: 0 2rem;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-50%);
}
.section__content {
  position: relative;
  z-index: 1;
  padding: 0 1rem;
}
@media screen and (min-width: 1024px) {
  .section {
    margin-bottom: 750px;
  }
  .section__header {
    transform: translateZ(-1px) scale(1.9);
  }
  .section__content {
    padding: 0;
    transform: translateZ(0);
  }
}

.boxgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-auto-rows: minmax(150px, auto);
  grid-gap: 2rem 0.5rem;
}
.boxgrid__item {
  display: flex;
}
.boxgrid__item--wide {
  grid-column: span 2;
}
@media screen and (min-width: 1280px) {
  .boxgrid__item--push {
    grid-column: span 2;
    padding-left: 50%;
  }
}

.box {
  display: flex;
  flex: 1 0 0;
  position: relative;
  padding: 2rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: #FFF;
  box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22);
  transform: scale(1);
  transition: all 0.25s ease;
  filter: brightness(100%);
}
.box:hover, .box:focus {
  transform: scale(1.07);
  filter: brightness(110%);
  z-index: 10;
}
.box--weather {
  background-color: #89CDCE;
}
.box--cost {
  background-color: #66AEE5;
}
.box--locations {
  background-color: #6C73DC;
}
.box--image, .box--video {
  padding: 0;
}
.box--video::before, .box--video::after {
  content: "";
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 10;
  transform: translate(-50%, -50%);
}
.box--video::before {
  width: 50px;
  height: 50px;
  background-color: #FFF;
  border-radius: 50%;
  box-shadow: 0 0 38px rgba(0, 0, 0, 0.3);
}
.box--video::after {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 0 10px 15px;
  border-color: transparent transparent transparent #121519;
  margin-left: 2px;
}
.box__img {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  -o-object-fit: cover;
     object-fit: cover;
  -o-object-position: center;
     object-position: center;
  border-radius: 0.5rem;
}

.scrollctrl {
  display: none;
  justify-content: center;
  width: 50vw;
  height: 50vw;
  padding: 0;
  position: fixed;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  background-color: transparent;
  left: 50%;
  margin-left: -25%;
}
.scrollctrl:hover, .scrollctrl:focus {
  background-color: rgba(255, 255, 255, 0.035);
}
.scrollctrl--prev {
  top: 0;
  padding-top: 44%;
  align-items: flex-end;
  transform: translateY(-42vw);
}
.scrollctrl--next {
  bottom: 0;
  padding-bottom: 44%;
  transform: translateY(42vw);
}
@media screen and (min-width: 1024px) {
  .scrollctrl {
    display: flex;
  }
}

.text--large {
  font-size: 2rem;
  font-weight: 200;
}

.arrow {
  display: inline-block;
  padding: 3px;
  border-style: solid;
  border-width: 0 2px 2px 0;
}
.arrow--large {
  padding: 8px;
  border-width: 0 1px 1px 0;
}
.arrow--right {
  transform: rotate(-45deg);
}
.arrow--left {
  transform: rotate(135deg);
}
.arrow--up {
  transform: rotate(-135deg);
}
.arrow--down {
  transform: rotate(45deg);
}

.media {
  display: flex;
  align-items: center;
  padding: 2rem;
}
.media__img {
  width: 60px;
  height: 60px;
  margin-right: 1rem;
  border-radius: 0.25rem;
  -o-object-position: center center;
     object-position: center center;
  -o-object-fit: cover;
     object-fit: cover;
}
.media__content {
  margin: 0;
}

.user {
  margin-left: auto;
  text-align: center;
  padding-top: 2rem;
}
.user__name {
  display: block;
  font-size: 1.5rem;
  font-weight: 200;
}
.user__img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin-bottom: 0.5rem;
  box-shadow: 0 0 38px rgba(0, 0, 0, 0.3);
}

.btn {
  display: flex;
  flex: 0 0 50px;
  justify-content: center;
  align-items: center;
  width: 50px;
  height: 50px;
  border: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background-color: #FFF;
  margin: 0 0.5rem;
}

button:focus {
  outline: 0;
  border-color: #66AEE5;
  box-shadow: 0 0 0 1px #66AEE5;
}
</style>


</head>

<body  >
  <div class="app">
  <header class="header">
    <div class="header__left">
      <span>Digital Walls</span>
    </div>
    <div class="header__right">
      <p>Thu, 14 Jun | 16:20</p>
    </div>
  </header>
  
  <nav class="nav">
    <ul class="nav__menu">
      <li class="nav__item">
        <a href="#vienna" class="nav__link" data-scroll-to>
          <div class="media">
            <img src="//repo.bfw.wiki/bfwrepo/image/62de84ef6c5df.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_100,/quality,q_90" alt="" class="media__img">
            <p class="media__content">
              <strong>Vienna</strong><br />
              Austria
            </p>
          </div>
        </a>
      </li>
      <li class="nav__item">
        <a href="#lisbon" class="nav__link" data-scroll-to>
          <div class="media">
            <img src="//repo.bfw.wiki/bfwrepo/image/62edbeb67776a.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_100,/quality,q_90" alt="" class="media__img">
            <p class="media__content">
              <strong>Lisbon</strong><br />
              Portugal
            </p>
          </div>
        </a>
      </li>
      <li class="nav__item">
        <a href="#newyork" class="nav__link" data-scroll-to>
          <div class="media">
            <img src="//repo.bfw.wiki/bfwrepo/image/62f6f0a6e423c.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_100,/quality,q_90" alt="" class="media__img">
            <p class="media__content">
              <strong>New York</strong><br />
              USA
            </p>
          </div>
        </a>
      </li>
    </ul>
  </nav>
  
  <main class="main">
    <article class="section" id="vienna" data-section>
      <header class="section__header" style="background-image: url('//repo.bfw.wiki/bfwrepo/image/63114687db61b.png');">
        <h1 class="section__title">Vienna</h1>
        <p class="section__subtitle">48.21°N, 16.36°E</p>
        <div class="section__controls">
          <button class="btn btn--prev" title="Previous">
            <span class="arrow arrow--left"></span>
          </button>
          <button class="btn btn--next" title="Next">
            <span class="arrow arrow--right"></span>
          </button>
          <div class="user">
            <img src="//repo.bfw.wiki/bfwrepo/image/631a61d45333a.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_100,/quality,q_90" class="user__img" alt="" />
            <span class="user__name">Jamie</span>
          </div>
        </div>
      </header>
      <div class="section__content">
        <ul class="boxgrid">
          <li class="boxgrid__item">
            <a href="#" class="box box--weather">
              <p><span class="text--large">27°C</span&g.........完整代码请登录后点击上方下载按钮下载查看

网友评论0