自适应网站效果

代码语言:html

所属分类:布局界面

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

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Lato&amp;display=swap'>
<style>
  body {
  margin: 0;
}

.background {
  align-items: center;
  background: #524fae;
  display: flex;
  height: 500vh;
  justify-content: center;
  padding-top: 150px;
  width: 100vw;
}

.Header {
  align-items: center;
  background: white;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  display: flex;
  height: 100px;
  justify-content: center;
  position: fixed;
  text-align: center;
  top: 0;
  width: 100%;
  z-index: 10;
}
.Header.has-mobile-button .MobileNav-trigger {
  display: flex;
}
.Header-inner {
  display: flex;
  justify-content: space-between;
  transition: height 0.4s ease;
  width: 80vw;
}
.Header .logo {
  align-self: center;
  display: flex;
  height: 80px;
  margin-right: 60px;
  width: 200px;
}
.Header-nav {
  display: flex;
  flex-wrap: wrap;
  height: 0;
  justify-content: space-between;
  max-height: 105px;
  max-width: 940px;
  overflow: hidden;
  width: 100%;
}
.Header-nav-item {
  align-items: center;
  align-self: center;
  color: darkblue;
  display: flex;
  flex-shrink: 0;
  font-family: Lato, sans-serif;
  font-size: 20px;
  font-weight: bold;
  height: 100%;
  line-height: 32px;
  margin: 0 40px;
  transition: font-size 0.4s ease, padding 0.4s ease;
}
.Header-nav-item:last-child {
  margin-right: 0;
}
.Header-nav-item a {
  color: black;
  text-decoration: none;
}
.Header-nav-item:hover {
  color: darkblue !important;
}
.Header-nav:hover .Header-nav-item {
  color: rgba(0, 0, 139, 0.5);
}
@media screen and (min-width: 481px) {
  .Header-nav {
    height: auto;
  }
}

.container {
  align-content: flex-start;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-around;
  width: 80vw;
}
.container .card {
  background: white;
  background-position: center;
  background-size: cover;
  border-radius: 10px;
  height: 50vh;
  margin-bottom: 10%;
  width: 100%;
}

.MobileNav {
  height: calc(100% - 55px);
  left: 0;
  pointer-events: none;
  position: fixed;
  top: 70px;
  width: 100%;
  z-index: 9;
}
.MobileNav-inner {
  background: white;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100%;
  overflow-y: scroll;
  position: absolute;
  right: 0;
  transform: translate(0, -105%);
  transition: transform 0.4s ease, visibility 0.4s ease;
  visibility: hidden;
  width: 100%;
}
.MobileNav-inner .Button {
  letter-spacing: 1px;
  line-height: 3.8;
  margin: 20px -8px 20px;
  width: 100%;
}
.MobileNav-inner .MobileNav-trigger {
  display: none;
  position: absolute;
  right: 38px;
  top: 30px;
}
.MobileNav-item {
  color: navy;
  display: none;
  font-family: Lato, sans-serif;
  font-size: 24px;
  font-weight: bold;
  margin: 26px 0;
  transition: opacity 0.3s ease;
}
.MobileNav-item.is-visible {
  display: block;
}
.MobileNav-item-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
}
.MobileNav-item-title a {
  color: black;
  flex-shrink: 0;
  text-decoration: none;
}
.MobileNav-item-title span {
  min-width: 32px;
  position: relative;
  width: 100%;
}
.MobileNav-item-title span::after {
  border-left: 2px solid lightgray;
  border-top: 2px solid lightgray;
  content: "";
  display: block;
  height: 14px;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-75%) rotate(225deg);
  transition: transform 0.2s ease;
  width: 14px;
}
.MobileNav-overlay {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  transition: background 0.4s ease;
  width: 100%;
}
.MobileNav-trigger {
  align-items: center;
  align-self: center;
  cursor: pointer;
  display: none;
  flex-shrink: 0;
  height: 100%;
}
.MobileNav-trigger-inner {
  height: 12px;
  position: relative;
  width: 24px;
}
.MobileNav-trigger-inner::after {
  background: #524fae;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  top: 0;
  transform-origin: 0% 50%;
  transition: transform 0.2s ease;
  width: 100%;
}
.MobileNav-trigger-inner::before {
  background: #524fae;
  bottom: 0;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  transform-origin: 0% 50%;
  transition: transform 0.2s ease;
  width: 100%;
}
.MobileNav-trigger.is-active .MobileNav-trigger-inner::after {
  transform: translateY(-4px) rotate(45deg);
}
.MobileNav-trigger.is-active .MobileNav-trigger-inner::before {
  transform: translateY(3px) rotate(-45deg);
}
@media screen and (min-width: 481px) {
  .MobileNav {
    height: 100%;
    top: 0;
    z-index: 11;
  }
  .MobileNav-inner {
    padding-top: 90px;
    transform: translate(100%, 0);
    width: 375px;
  }
  .MobileNav-inner .MobileNav-trigger {
    display: block;
  }
  .MobileNav-trigger {
    display: none;
  }
}
@media screen and (min-width: 871px) {
  .MobileNav-inner {
    padding-top: 160px;
  }
}

.is-mobilenav-open {
  overflow-y: hidden;
}
.is-mobilenav-open .MobileNav {
  pointer-events: all;
}
.is-mobilenav-open .MobileNav-inner {
  transform: translate(0, 0);
  visibility: visible;
}
.is-mobilenav-open .MobileNav-overlay {
  background: rgba(0, 0, 0, 0.15);
}
</style>

</head>
<body translate="no">
<div class="background">
<div class="MobileNav" data-mobile-nav>
<div class="MobileNav-overlay" data-mobile-nav-overlay></div>
<div class="MobileNav-inner">
<div class="MobileNav-trigger" data-mobile-nav-trigger>
<div class="MobileNav-trigger-inner"></div>
</div>
<ul class="MobileNav-nav" data-mobile-nav-list>
<li class="MobileNav-item" data-mobile-nav-item="1">
<div class="MobileNav-item-title">
<a href="#">About</a>
</div>
</li>
<li class="MobileNav-item" data-mobile-nav-item="2">
<div class="MobileNav-item-title">
<a href="#">Products</a>
</div>
</li>
<li class="MobileNav-item" data-mobile-nav-item="3">
<div class="MobileNav-item-title">
<a href="#">Service.........完整代码请登录后点击上方下载按钮下载查看

网友评论0