teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

htmlソースの追加

2017/02/16 05:31

投稿

sox
sox

スコア12

title CHANGED
File without changes
body CHANGED
@@ -42,9 +42,7 @@
42
42
  -webkit-box-siging: border-box;
43
43
  box-siging: border-box;
44
44
  }
45
-
46
45
  }
47
-
48
46
  @media (min-width: 1040px) {
49
47
  /* 全体の横幅 */
50
48
  .container, .header-inner, .footer-inner {
@@ -53,7 +51,6 @@
53
51
  }
54
52
  }
55
53
 
56
-
57
54
  /* ↓ここで img に記事の幅に揃えるよう指定していることになっています。*/
58
55
 
59
56
  /*--------------大きい画像用の設定---------------*/
@@ -63,7 +60,6 @@
63
60
  }
64
61
  ```
65
62
 
66
- **.contents** の **flex** の最後の値は **auto** でもいい筈なんですが、これだと文章が横長にかなりはみ出てしまうので **600px** で区切っています。
67
63
  さらに参考になるかわかりませんが、single.phpのhtmlも下記に記しておきます。
68
64
 
69
65
  ```html
@@ -98,19 +94,113 @@
98
94
 
99
95
  <?php get_footer(); ?>
100
96
  ```
101
- ちなみに、divクラスの **.catch** であるサムネイルは下記の指定で記事の幅に揃えて出力されてレスポンシブになっております。
102
97
 
103
- ```css
104
- /* アイキャッチ */
105
- .catch {
106
- margin: 10px 0 20px;
107
- max-width: 100%;
108
- height: auto
109
- }
98
+ 下記は当該ページのソースです。
99
+ 記事の文章途中の赤字の部分が記事幅を思いっきりはみ出した画像のソースです。
100
+
101
+
102
+ ```html
103
+
104
+ <!DOCTYPE html>
105
+ <html lang="ja">
106
+
107
+ <head>
108
+ <meta charset="UTF-8">
109
+ <title>
110
+ おいしい朝ごはんを食べたい! / PICNIC </title>
111
+
112
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
113
+
114
+ <link rel="stylesheet" href="http://127.0.0.1:8080/wordpress/wp-content/themes/mythemeee/style.css?VER=1487221876"> <!-- 最新のphpを読み込ませる -->
115
+
116
+ <link rel="stylesheet" href="/css/sanitize.css">
117
+
118
+ <link rel='dns-prefetch' href='//s.w.org' />
119
+ <link rel="alternate" type="application/rss+xml" title="PICNIC &raquo; おいしい朝ごはんを食べたい! のコメントのフィード" href="http://127.0.0.1:8080/wordpress/breakfast/feed/" />
120
+ <script type="text/javascript">
121
+ window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/2.2.1\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/2.2.1\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/127.0.0.1:8080\/wordpress\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.7.2"}};
122
+ !function(a,b,c){function d(a){var b,c,d,e,f=String.fromCharCode;if(!k||!k.fillText)return!1;switch(k.clearRect(0,0,j.width,j.height),k.textBaseline="top",k.font="600 32px Arial",a){case"flag":return k.fillText(f(55356,56826,55356,56819),0,0),!(j.toDataURL().length<3e3)&&(k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,65039,8205,55356,57096),0,0),b=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57331,55356,57096),0,0),c=j.toDataURL(),b!==c);case"emoji4":return k.fillText(f(55357,56425,55356,57341,8205,55357,56507),0,0),d=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55357,56425,55356,57341,55357,56507),0,0),e=j.toDataURL(),d!==e}return!1}function e(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i,j=b.createElement("canvas"),k=j.getContext&&j.getContext("2d");for(i=Array("flag","emoji4"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);
123
+ </script>
124
+ <style type="text/css">
125
+ </style>
126
+ <link rel='https://api.w.org/' href='http://127.0.0.1:8080/wordpress/wp-json/' />
127
+ <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://127.0.0.1:8080/wordpress/xmlrpc.php?rsd" />
128
+ <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://127.0.0.1:8080/wordpress/wp-includes/wlwmanifest.xml" />
129
+ <link rel='prev' title='手土産に何を持っていくかが大きな問題' href='http://127.0.0.1:8080/wordpress/temiyage/' />
130
+ <meta name="generator" content="WordPress 4.7.2" />
131
+ <link rel="canonical" href="http://127.0.0.1:8080/wordpress/breakfast/" />
132
+ <link rel='shortlink' href='http://127.0.0.1:8080/wordpress/?p=13' />
133
+ <link rel="alternate" type="application/json+oembed" href="http://127.0.0.1:8080/wordpress/wp-json/oembed/1.0/embed?url=http%3A%2F%2F127.0.0.1%3A8080%2Fwordpress%2Fbreakfast%2F" />
134
+ <link rel="alternate" type="text/xml+oembed" href="http://127.0.0.1:8080/wordpress/wp-json/oembed/1.0/embed?url=http%3A%2F%2F127.0.0.1%3A8080%2Fwordpress%2Fbreakfast%2F&#038;format=xml" />
135
+ </head>
136
+
137
+ <body class="post-template-default single single-post postid-13 single-format-standard logged-in">
138
+
139
+ <header>
140
+ <div class="header-inner">
141
+ <div class="site">
142
+ <h1><a href="http://127.0.0.1:8080/wordpress">
143
+ PICNIC </a></h1>
144
+ </div>
145
+ </div> <!-- header-inner -->
146
+
147
+ </header>
148
+ <div class="container">
149
+ <div class="contents">
150
+
151
+ <h1>おいしい朝ごはんを食べたい!</h1>
152
+
153
+ <div class="catch">
154
+ <img width="747" height="498" src="http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-1024x682.jpg" class="attachment-large size-large wp-post-image" alt="" srcset="http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-1024x682.jpg 1024w, http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-300x200.jpg 300w, http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-768x512.jpg 768w, http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779.jpg 1280w" sizes="(max-width: 747px) 100vw, 747px" /> <p class="wp-caption-text">
155
+ <a href="https://pixabay.com/users/JESHOOTS/">JESHOOTS</a> / Pixabay </p>
156
+ </div>
157
+
158
+
159
+ <p>とあるところで目にした言葉「一日の計は朝にあり」。何事も最初が肝心、はじめにしっかり計画を立てよう、といった意味のことわざですが、私が連想したのは朝ごはんでした。何でも食べ物に結びつけてしまう今日このごろです。</p>
160
+ <p>朝ごはんは食べる派ですか? それとも食べない派? 「1日のエネルギー源だから食べた方がいい」とか、「午前中は老廃物を出す時間だから食べない方がいい」とか、まったく相反する意見があって、どちらに従ったものなのか迷ってしまいます。</p>
161
+ <div id="attachment_48" style="width: 1290px" class="wp-caption aligncenter"><a href="http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779.jpg"><img class="size-full wp-image-48" src="http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779.jpg" alt="" width="1280" height="853" srcset="http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779.jpg 1280w, http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-300x200.jpg 300w, http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-768x512.jpg 768w, http://127.0.0.1:8080/wordpress/wp-content/uploads/2017/02/クロワッサン コーヒー_1487131779-1024x682.jpg 1024w" sizes="(max-width: 1280px) 100vw, 1280px" /></a><p class="wp-caption-text"><a href="https://pixabay.com/users/JESHOOTS/">JESHOOTS</a> / Pixabay</p></div>
162
+ <p>どちらの意見も一理あるような気がするのですが、おいしそうな朝ごはんを見ると食べたくなってしまう私です。ホテルならあたたかい珈琲にクロワッサン、ジャム、ベーコンエッグ…。旅館ならあたたかいお味噌汁にご飯、納豆、焼き魚…。</p>
163
+ <p>残念ながら自分でこれだけの食材を買い揃え、毎朝作って準備するのは難しいので、結果的に「朝ごはん食べない派」になっているんですけどね。</p>
164
+
165
+
166
+ </div> <!--- contents --->
167
+
168
+ <div class="sub">
169
+ <aside class="mymenu">
170
+ <h2>新着記事</h2>
171
+ <ul>
172
+ <li><a href="http://127.0.0.1:8080/wordpress/breakfast/">
173
+ おいしい朝ごはんを食べたい! </a></li>
174
+ <li><a href="http://127.0.0.1:8080/wordpress/temiyage/">
175
+ 手土産に何を持っていくかが大きな問題 </a></li>
176
+ <li><a href="http://127.0.0.1:8080/wordpress/yasai/">
177
+ 野菜をたくさん食べるために考えたこと </a></li>
178
+
179
+ </ul>
180
+ </aside>
181
+ </div>
182
+
183
+ </div> <!--- container --->
184
+
185
+ <footer>
186
+ <div class="footer-inner">
187
+ <div class="copyright">
188
+ <p>Copyright © 2017
189
+ PICNIC </p>
190
+ </div>
191
+ </div>
192
+
193
+ </footer>
194
+
195
+ </body>
196
+
197
+ </html>
110
198
  ```
111
199
 
112
- どうぞご回答よろしくお願いいたします。
200
+ よろしくお願いいたします。
113
201
 
202
+
203
+
114
204
  ###試したこと
115
205
  「大きい画像用の設定」にて、**max-widht: 100%** ではなく **width: 600px** に置き換えてみましたが、画像が600pxで表示されるだけで文章は画像の大きい画像サイズの 1024px あたりまで幅が広がってしまいました。
116
206
 

1

html を書き加えました。

2017/02/16 05:31

投稿

sox
sox

スコア12

title CHANGED
File without changes
body CHANGED
@@ -54,6 +54,8 @@
54
54
  }
55
55
 
56
56
 
57
+ /* ↓ここで img に記事の幅に揃えるよう指定していることになっています。*/
58
+
57
59
  /*--------------大きい画像用の設定---------------*/
58
60
  img, .wp-caption {
59
61
  max-width: 100%;
@@ -62,8 +64,53 @@
62
64
  ```
63
65
 
64
66
  **.contents** の **flex** の最後の値は **auto** でもいい筈なんですが、これだと文章が横長にかなりはみ出てしまうので **600px** で区切っています。
67
+ さらに参考になるかわかりませんが、single.phpのhtmlも下記に記しておきます。
65
68
 
69
+ ```html
70
+ <?php get_header(); ?>
66
71
 
72
+ <div class="container">
73
+ <div class="contents">
74
+
75
+ <?php if(have_posts()): while(have_posts()): the_post(); ?>
76
+ <h1><?php the_title(); ?></h1>
77
+
78
+ <?php if( has_post_thumbnail() ): ?>
79
+ <div class="catch">
80
+ <?php the_post_thumbnail( 'large' ); ?>
81
+ <p class="wp-caption-text">
82
+ <?php echo get_post( get_post_thumbnail_id() )->post_excerpt; ?>
83
+ </p>
84
+ </div>
85
+ <?php endif; ?>
86
+
87
+ <?php the_content(); ?>
88
+
89
+ <?php endwhile; endif; ?>
90
+
91
+ </div> <!--- contents --->
92
+
93
+ <div class="sub">
94
+ <?php get_sidebar(); ?>
95
+ </div>
96
+
97
+ </div> <!--- container --->
98
+
99
+ <?php get_footer(); ?>
100
+ ```
101
+ ちなみに、divクラスの **.catch** であるサムネイルは下記の指定で記事の幅に揃えて出力されてレスポンシブになっております。
102
+
103
+ ```css
104
+ /* アイキャッチ */
105
+ .catch {
106
+ margin: 10px 0 20px;
107
+ max-width: 100%;
108
+ height: auto
109
+ }
110
+ ```
111
+
112
+ どうぞご回答よろしくお願いいたします。
113
+
67
114
  ###試したこと
68
115
  「大きい画像用の設定」にて、**max-widht: 100%** ではなく **width: 600px** に置き換えてみましたが、画像が600pxで表示されるだけで文章は画像の大きい画像サイズの 1024px あたりまで幅が広がってしまいました。
69
116