開発中、これは Chrome と Safari のデスクトップでのテストでした。そして、私が見ているものがモバイルでどのように見えるかを想定して、ウィンドウの幅を狭めます.
望ましい結果 (Safari バージョン 6.0.5 (8536.30.1)):
ただし、iPhone のモバイル Safari でこれを開いたところ、次のようなメッセージが表示されました。
モバイル デバイスの幅を狭めるには、どのプロパティが不足していますか?
ビュー/レイアウト/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Birthday</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="avatar"><%= image_tag "avatar.jpg" %></div>
<h1>Drew Wyatt 24th Annual Nameday Celebration</h1>
</div>
<div id="main">
<%= yield %>
</div>
</div>
</body>
</html>
ビュー/リスト/index.html.erb
<h2>The List</h2>
<p class="page_description">You asked for it, here it is: the ultimate 2013 birthday list for me, Drew Wyatt.
You can get me none of this, or all of this (although please don't - some of this is kindof expensive); this is just a list of ideas to get you started.</p>
<% @items.each do |item| %>
<div class="item">
<h3><%= item.name %></h3>
<div class="image">
<%= link_to(image_tag(item.image), item.link, target: "_blank") %>
</div>
<p><%= item.description %></p>
<span class="price"><%= number_to_currency item.price %></span><br /><br />
</div>
<% end %>
アプリケーション.css
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
* {
margin: 0;
padding: 0;
}
a, a:hover {
background: #fff;
text-decoration: none;
}
#wrapper {
margin: 0;
padding: 0;
}
#header {
width: 100%;
height: 144px;
display: block;
position: relative;
background: #f3b819;
}
#avatar {
width: 145px;
height: 147px;
float: left;
}
h1 {
position: absolute;
bottom: 0;
left: 160px;
font-size: 30px;
line-height: 32px;
}
#main {
padding: 10px;
}
p.page_description {
font-size: 20px;
line-height: 22px;
}
h2 {
font-size: 24px;
margin-bottom: 10px;
border-bottom: 2px solid;
padding-bottom: 2px;
}
h3 {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
p {
font-size: 14px;
margin-bottom: 10px;
}
list.css.scsss
// Place all the styles related to the List controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.item {
height: auto;
/*min-height: 160px;*/
margin-bottom: 10px;
.image {
float: left;
padding-bottom: 10px;
padding-right: 10px;
}
.price {
font-weight: bold;
}
span.link a {
color: #f3b819;
background: #fff;
text-decoration: none;
font-weight: bold;
&:hover {
background: #fff;
text-decoration: underline;
}
}
border-bottom: 2px solid #999;
}
.item:after {
content: "";
display: table;
clear: both;
}