【ソースコード】初級編:ストアサイト(書店)/1カラム

style.css

style.css

@charset "UTF-8";

html {
  font-size: 100%;
}
body {
  font-family: "Arial", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  font-size: 0.875rem;
  color: #2a2a2a;
}
a {
  text-decoration: none;
}
a:hover {
  opacity: 0.7;
}
img {
  max-width: 100%;
}
li {
  list-style: none;
}
/*
中身のコンテンツの最大幅を設定し、共通で使用
*/
.wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 5%;
}
.sec-title {
  font-size: 1.5rem;
  margin-bottom: 20px;
}
/*
ボタン
「display: inline-block;」を設定して
paddingでボタンに幅と高さを持たせる。
*/
.btn {
  color: #2a2a2a;
  border: solid 1px #2a2a2a;
  display: inline-block;
  font-size: 0.750rem;
  padding: 14px 36px;
  margin-top: 30px;
}

/*-------------------------------------------
ヘッダー
-------------------------------------------*/
/*
height: 100vh;
メインビジュアルを画面の高さにあわせる
position: relative;
ロゴの位置を固定するため、親要素の「position」に「relative」を設定
*/
#header {
  height: 100vh;
  background-image: url(../img/mainvisual.jpg);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  margin-bottom: 80px;
  position: relative;
}
/*
ロゴ
「position: absolute;」を設定してから、
 top と right で位置を調整
*/
#header .site-title {
  position: absolute;
  top: 30px;
  right: 30px;
}

/*-------------------------------------------
Magazine
-------------------------------------------*/
#magazine {
  text-align: center;
  margin-bottom: 80px;
}
#magazine .flex-item {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
}
/*
テキストを上に重ねるために、
親要素の「position」に「relative」を設定
*/
#magazine .flex-item .item {
  width: 49%;
  position: relative;
}
/*
「position: absolute;」を設定し、
top、left、rightで位置を調整
*/
#magazine .flex-item .item .text {
  max-width: 290px;
  color: #fff;
  font-weight: bold;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 15px 0;
  margin: 0 auto;
  position: absolute;
  top: 40%;
  left: 0;
  right: 0;
}
#magazine .flex-item .item .title {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

/*-------------------------------------------
Fashion
-------------------------------------------*/
#fashion {
  height: 520px;
  background-image: url(../img/fashion.jpg);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  text-align: center;
  padding-top: 60px;
  margin-bottom: 80px;
}

/*-------------------------------------------
Catalog & Antique
-------------------------------------------*/
.catalog-antique {
  background-color: #f5f5f5;
  padding: 60px 0;
}
.catalog-antique .sec-title {
  margin-bottom: 40px;
}
.catalog-antique .flex-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.catalog-antique .item {
  width: 48%;
  text-align: center;
}
.catalog-antique .item img {
  width: 100%;
}
.catalog-antique .item p {
  margin-bottom: 30px;
  text-align: left;
}
.catalog-antique .item p:last-child {
  margin-bottom: 0;
}

/*-------------------------------------------
フッター
-------------------------------------------*/
#footer {
  background-color: #333;
  font-size: 0.750rem;
}
#footer .flex-item {
  display: flex;
  justify-content: space-between;
  color: #fff;
  padding-top: 100px;
  padding-bottom: 100px;
}
#footer .item {
  width: 33%;
  line-height: 2;
}
#footer .item:first-child {
  padding: 60px 0;
}
#footer .item li::before {
  content: "-";
  margin-right: 5px;
}
#footer .item .title {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 10px;
}
#footer .copyright {
  background-color: #fff;
  text-align: center;
  padding: 30px 0;
}

/*-------------------------------------------
SP
-------------------------------------------*/
@media screen and (max-width: 896px) {
  /*-------------------------------------------
  Magazine
  -------------------------------------------*/
  #magazine .flex-item {
    flex-direction: column;
  }
  #magazine .flex-item .item {
    width: 100%;
  }
  #magazine .flex-item .item:first-child {
    margin-bottom: 30px;
  }

  /*-------------------------------------------
  Fashion
  -------------------------------------------*/
  #fashion {
    padding-top: 35px;
    margin-bottom: 50px;
  }

  /*-------------------------------------------
  Catalog & Antique
  -------------------------------------------*/
  .catalog-antique {
    padding: 30px 0;
  }
  .catalog-antique .flex-item {
    flex-direction: column;
  }
  .catalog-antique .item {
    width: 100%;
  }
  .catalog-antique .item:first-child {
    margin-bottom: 60px;
  }

  /*-------------------------------------------
  フッター
  -------------------------------------------*/
  #footer .flex-item {
    flex-direction: column;
    padding-top: 30px;
    padding-bottom: 30px;
  }
  #footer .item {
    width: 100%;
    margin-bottom: 30px;
  }
  #footer .item:first-child {
    text-align: center;
    padding: 0;
  }
}