Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

Responsive Website Code

body {
  font-size: 15px;
}

button {
  background: #ffc600;
  border: 0;
  padding: 10px 20px;
}

img {
  max-width: 100%;
}

/* .wrapper */

.wrapper {
  display: grid;
  grid-gap: 20px;
}

.top {
  display: grid;
  grid-gap: 20px;
  grid-template-areas:
    "hero hero cta1"
    "hero hero cta2"
}

.hero {
  grid-area: hero;
  min-height: 400px;
  background: white url(images/taco.jpg);
  background-size: cover;
  background-position: bottom right;
  padding: 50px;
  display: flex;
  flex-direction: column;
  align-items: start;
  justify-content: center;
}

.hero > * {
  background: var(--yellow);
  padding: 5px;
}

.cta {
  background: var(--yellow);
  display: grid;
  align-items: center;
  justify-items: center;
  align-content: center;
}

.cta p {
  margin: 0;
}

.cta1 {
  grid-area: cta1;
}

.cta2 {
  grid-area: cta2;
}

.price {
  font-size: 60px;
  font-weight: 300;
}

/* Navigation */

.menu ul {
  display: grid;
  grid-gap: 10px;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.menu a {
  background: var(--yellow);
  display: block;
  text-decoration: none;
  padding: 10px;
  text-align: center;
  color: var(--black);
  text-transform: uppercase;
  font-size: 20px;
}

[aria-controls="menu-list"] {
  display: none;
}

/* Features! */

.features {
  display: grid;
  grid-gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.feature {
  background: white;
  padding: 10px;
  border: 1px solid white;
  text-align: center;
  box-shadow: 0 0 4px  rgba(0,0,0,0.1);
}

.feature .icon {
  font-size: 50px;
}
.feature p {
  color: rgba(0,0,0,0.5);
}

/* About Section */

.about {
  background: white;
  padding:50px;
  display: grid;
  grid-template-columns: 400px 1fr;
  align-items: center;
}

/* Gallery! */

.gallery {
  display: grid;
  grid-gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.gallery img {
  width: 100%;
}

.gallery h2 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-gap: 20px;
  align-items: center;
}

.gallery h2:before, .gallery h2:after {
  display: block;
  content: '';
  height: 10px;
  background: linear-gradient(to var(--direction, left), var(--yellow), transparent);
}

.gallery h2:after {
  --direction: right;
}

@media (max-width: 1000px) {
  .menu {
    perspective: 800px;
  }
  [aria-controls="menu-list"] {
    display: block;
    margin-bottom: 10px;
  }

  .menu ul {
    max-height: 0;
    overflow: hidden;
    transform: rotateX(90deg);
    transition: all 0.5s;
  }

  [aria-expanded="true"] ~ ul {
    display: grid;
    max-height: 500px;
    transform: rotateX(0);
  }

  [aria-expanded="false"] .close {
    display: none;
  }

  [aria-expanded="true"] .close {
    display: inline-block;
  }

  [aria-expanded="true"] .open {
    display: none;
  }

}

@media (max-width: 700px) {
  .top {
    grid-template-areas:
      "hero hero"
      "cta1 cta2"
  }
  /* About */
  .about {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .top {
    grid-template-areas:
      "hero"
      "cta1"
      "cta2"
  }
}
Source by jolly-kalam-23776e.netlify.app #
 
PREVIOUS NEXT
Tagged: #Responsive #Website #Code
ADD COMMENT
Topic
Name
7+7 =