WEBサイト制作の勉強

WEBサイト制作の勉強の為の解説ブログです。

フェリカテクニカルアカデミー

既存のPCサイトをレスポンシブ化する

f:id:yachin29:20160725191614p:plain


記述例

@charset "utf-8";
/* CSS Document */

/*reset*/
html, body, div, h1, h2, h3, h4, p, ul, li, dl, dt, dd,header, nav, footer {
  margin:0;
  padding:0;
  line-height:1.0;
  font-family:"Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}
a {
  text-decoration:none;
  color:#222;
}

ul {
  list-style:none;
}
img {
  border:0;
  vertical-align:bottom;
}

/*PCレイアウト*/
#container {
  width: 960px;
  margin:0 auto;
  position: relative;
}
header {
  background: #F9E4C0;
  overflow:hidden;
  padding-top: 10px;
}
header h1  {
  font-size:30px;
  position: absolute;
  top: 50px;
  left: 100px;
}
header .text{
  font-size: 14px;
  position: absolute;
  top: 30px;
  left: 100px;
}
header .logo {
  position:absolute;
  top:20px;
  left:20px;
}
header nav {
  float: right;
  margin: 0 10px 10px 0;
}
header ul {
  overflow: hidden;
}
header li {
  float: left;
  margin-right: 20px;
}
header li:last-child {
  margin-right:0;
}
header li a {
  display: block;
  width:140px;
  height:80px;
  background:#FFF9CC;
  text-align: center;
  line-height: 80px;
}

/*メイン部分*/
#main {
  overflow: hidden;
  padding-top: 40px;
}
#mainText {
  width:600px;
  float: left;
}
h2 {
  font-size: 40px;
  font-weight:normal;
  line-height: 1.6;
}
.textInfo {
  line-height:1.6;
  margin-bottom: 20px;
}
p#mainImg {
  width: 300px;
  float: right;
  margin-top: 30px;
}
#mainShop a {
  display: block;
  width:500px;
  height:60px;
  background:#FFF9CC;
  border: 1px #333 solid;
  box-sizing: border-box;
  margin-bottom: 40px;
  text-align: center;
  line-height:60px;
  font-size:20px;
}

/*メニュー部分*/
#menu {
  background:#FFE380;
  overflow: hidden;
}
#menuInner {
  overflow: hidden;
  margin: 30px 0;
  padding: 0 10px;
}
#menu h3 {
  width:320px;
  float: left;
  font-size: 40px;
  font-weight: normal;
}
#all a {
  display: block;
  float: right;
  background:#FFC;
  width:220px;
  height:50px;
  text-align:center;
  line-height:50px;
}
#menuPhoto {
  overflow: hidden;
}
#menu h4 {
  text-align: center;
  font-size:18px;
  font-weight:normal;
  margin-bottom: 10px;
}
.menuFood {
  float: left;
  width:220px;
  margin:10px;
}
.photo img {
  border-radius: 20px;
}
.photoText {
  margin: 10px 0 30px 0;
  line-height: 1.5;
}

/*お知らせ部分*/
#info {
  overflow: hidden;
  padding-top: 40px;
}
#info h3 {
  font-size:28px;
  font-weight: normal;
  margin-bottom: 30px;
}
#infoShop {
  float: left;
  width: 450px;
  margin:0 0 30px 10px;
}
#info dt, #info dd {
  float: left;
  margin-bottom: 20px;
}
#info dd {
margin-left:10px;
}
#sns {
  float: right;
  width:480px;
  overflow:hidden;
}
#sns p {
  font-size:28px;
  text-align: center;
  margin-bottom: 10px;
}
#sns li {
  float: left;
  margin: 10px;
}
#sns li a {
  display: block;
  width:220px;
  height:60px;
  border-radius: 8px;
  background: #FFCC66;
  line-height: 60px;
  text-align:center;
}

/*アクセス部分*/
#access {
  background: #FACFB3;
  padding: 10px;
}
#access h3 {
  font-size: 28px;
  margin-top: 20px;
  font-weight: normal;
  width:120px;
  float: left;
}
#access h4 {
  width:190px;
  height: 40px;
  background: #FFC;
  float: left;
  font-weight: normal;
  margin:10px 0 40px 40px;
  text-align:center;
  line-height:40px;
}
#access dl {
  clear: both;
  overflow: hidden;
  margin-bottom: 30px;
}
#access dt, #access dd {
  float: left;
  line-height: 1.6;
}
#access dt {
  width: 80px;
  height: 70px;
}
#access dd {
  width: 380px;
  height: 70px;
}
/*フッター部分*/
footer {
  background: #FFF683;
  height:60px;
  text-align:center;
}
footer p {
  line-height: 60px;
  font-size: 18px;
}



@media screen and (max-width:959px){
img {
  max-width:100%;
}
#container {
  width:100%;
}
header h1  {
  font-size:30px;
  top: 45px;
  left: 80px;
}
header .text{
  font-size: 12px;
  top: 25px;
  left: 80px;
}
header .logo {
  width:50px;
  top:20px;
  left:10px;
}
header nav {
  float: none;
  margin: 80px 0 0 0;
}
header ul {
  overflow: hidden;
}
header li {
  float: left;
  width:33.33%;
  margin-right: 0;
  border-right:2px solid #FFF;
  box-sizing: border-box;
}
header li:last-child {
  border-right: none;
}
header li a {
  width:100%;
  height:40px;
  line-height: 40px;
}

/*メイン部分*/
#main {
  width: 96%;
  padding: 20px 2% 0 2%;
}

#mainText {
  width:90%;
  float: none;
  margin: 0 auto;
}
h2 {
  font-size: 20px;
  margin-bottom: 20px;
}
.textInfo {
  font-size: 14px;
}
p#mainImg {
  width: 100%;
  float: none;
  margin-top: 0;
  margin-bottom: 20px;
  text-align: center;
}
#mainShop a {
  width: 80%;
  margin: 0 auto 40px;
}


/*メニュー部分*/
#menuInner {
  padding: 0;
}
#menu h3 {
  width:100%;
  float:  none;
  font-size: 28px;
  text-align: center;
  margin-bottom: 20px;
}
#all a {
  width:200px;
  height:40px;
  float: none;
  line-height:40px;
  margin: 30px auto 0;
}
#menu h4 {
  font-size:14px;
}
#menuPhoto {
  width: 92%;
  padding:0 4%;
  margin: 0 auto;
}
.menuFood {
  width:48%;
  height: 320px;
  margin:0;
}
.menuFood:nth-child(odd) {
  margin-right:4%;
}
#menu .photo {
  text-align: center;
}
.photoText {
  font-size:14px;
}


/*お知らせ部分*/
#info h3 {
  font-size:22px;
}
#infoShop {
  float: none;
  width: 100%;
}
#info dt, #info dd {
  float: none;
}
#info dt {
    margin-bottom: 10px;
}
#sns {
  float: none;
  width:100%;
  margin-bottom:30px;
}
#sns p {
  font-size:22px;
  margin: 20px 0 10px;
}
#sns li {
  float: left;
  margin: 2%;
  width:46%;
}
#sns li a {
  width:100%;
}


/*アクセス部分*/

#access h3 {
  font-size: 28px;
  width:100%;
  text-align:center;
  float: none;
}
#access h4 {
  width:70%;
  height: 40px;
  float: none;
  margin:20px auto 40px;
  line-height:40px;
}
#access dt, #access dd {
  float: none;
  font-size: 14px;
  line-height: 1.4;
}
#access dt {
  width: 100%;
  height:auto;
  font-weight:bold;
}
#access dd {
  width: 100%;
  height:auto;
  margin-bottom: 20px;
}


/*フッター部分*/
footer {
  background: #FFF683;
  height:60px;
  text-align:center;
}
footer p {
  line-height: 60px;
  font-size: 14px;
}
}