Contents
WordPressで、会話形式の表現をしてみたいと思います。が、・・・「Speach Bubble」プラグインを使わない本当の理由とは?
以下の画像のような、吹き出しバブルを使って、
ライン風の会話形式に、話している人の画像を表示させるようにしたいと思いました。
関連リンク
本当は、Wordpressのプラグイン「Speach Bubble」を使って、簡単に済ませようと考えていました。
が、・・・
最終更新が2年前ということで、今後のアップデートをあまり期待できないかも知れないという不安に駆られて、
結局のところ、最終的には、CSS(スタイルシート)とHTMLで、構築する方法を選択しました。
その試行錯誤を、ここに備忘記録として残しておこうと思います。
また、いつの日にか、更なるバージョンへアップしたい時に、『踏み台』になってくれるでしょうから!!!
CSS(スタイルシート)3人会話形式用
ここでは、3人の登場人物を用意します。
1人ごとに、吹き出しの色を変えたかったので、
パターンを3種類用意することになりました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
/*******吹き出し:レスポンシブ*******/ body{ width:100%; min-width: 320px; margin:0; padding: 0; } #wrapper{ margin: 20px auto; width:96%; } .arrow_answer, .arrow_question { position: relative; background: #fff; border: 1px solid #c8c8c8; border-radius: 10px; width:75%; font-size: 16px; padding:3%; } .arrow_question { float: right; } .arrow_answer:after, .arrow_answer:before, .arrow_question:after, .arrow_question:before { top: 30%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_question:after, .arrow_question:before { right: 100%; } .arrow_answer:after, .arrow_answer:before{ left: 100%; } .arrow_answer:after, .arrow_question:after { border-color: rgba(255, 255, 255, 0); border-width: 8px; margin-top: -8px; } .arrow_answer:after{ border-left-color: #fff; } .arrow_question:after{ border-right-color: #fff; } .arrow_answer:before, .arrow_question:before { border-color: rgba(200, 200, 200, 0); border-width: 9px; margin-top: -9px; } .arrow_answer:before{ border-left-color: #c8c8c8; } .arrow_question:before { border-right-color: #c8c8c8; } .question_image{ float: left; width:15%; font-size:12px; text-align:center } .answer_image{ float: right; width:15%; font-size:12px; text-align:center } .answer_image img, .question_image img{ border-radius: 0px; width: 100% } .question_Box{ width: 100%; overflow: hidden; margin-bottom: 8%; } /*******吹き出し:レスポンシブ=>mirai*******/ body{ width:100%; min-width: 320px; margin:0; padding: 0; } #wrapper{ margin: 20px auto; width:96%; } .arrow_answer_mirai, .arrow_question_mirai { position: relative; background: #fff2f9; border: 1px solid #c8c8c8; border-radius: 10px; width:75%; font-size: 16px; padding:3%; } .arrow_question_mirai { float: right; } .arrow_answer_mirai:after, .arrow_answer_mirai:before, .arrow_question_mirai:after, .arrow_question_mirai:before { top: 30%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_question_mirai:after, .arrow_question_mirai:before { right: 100%; } .arrow_answer_mirai:after, .arrow_answer_mirai:before{ left: 100%; } .arrow_answer_mirai:after, .arrow_question_mirai:after { border-color: rgba(255, 255, 255, 0); border-width: 8px; margin-top: -8px; } .arrow_answer_mirai:after{ border-left-color: #fff; } .arrow_question_mirai:after{ border-right-color: #fff; } .arrow_answer_mirai:before, .arrow_question_mirai:before { border-color: rgba(200, 200, 200, 0); border-width: 9px; margin-top: -9px; } .arrow_answer_mirai:before{ border-left-color: #c8c8c8; } .arrow_question_mirai:before { border-right-color: #c8c8c8; } .question_image{ float: left; width:15%; font-size:12px; text-align:center } .answer_image{ float: right; width:15%; font-size:12px; text-align:center } .answer_image img, .question_image img{ border-radius: 0px; width: 100% } .question_Box{ width: 100%; overflow: hidden; margin-bottom: 8%; } /*******吹き出し:レスポンシブ=>takeru*******/ body{ width:100%; min-width: 320px; margin:0; padding: 0; } #wrapper{ margin: 20px auto; width:96%; } .arrow_answer_takeru, .arrow_question_takeru { position: relative; background: #e3fff1; border: 1px solid #c8c8c8; border-radius: 10px; width:75%; font-size: 16px; padding:3%; } .arrow_question_takeru { float: right; } .arrow_answer_takeru:after, .arrow_answer_takeru:before, .arrow_question_takeru:after, .arrow_question_takeru:before { top: 30%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_question_takeru:after, .arrow_question_takeru:before { right: 100%; } .arrow_answer_takeru:after, .arrow_answer_takeru:before{ left: 100%; } .arrow_answer_takeru:after, .arrow_question_takeru:after { border-color: rgba(255, 255, 255, 0); border-width: 8px; margin-top: -8px; } .arrow_answer_takeru:after{ border-left-color: #fff; } .arrow_question_takeru:after{ border-right-color: #fff; } .arrow_answer_takeru:before, .arrow_question_takeru:before { border-color: rgba(200, 200, 200, 0); border-width: 9px; margin-top: -9px; } .arrow_answer_takeru:before{ border-left-color: #c8c8c8; } .arrow_question_takeru:before { border-right-color: #c8c8c8; } .question_image{ float: left; width:15%; font-size:12px; text-align:center } .answer_image{ float: right; width:15%; font-size:12px; text-align:center } .answer_image img, .question_image img{ border-radius: 0px; width: 100% } .question_Box{ width: 100%; overflow: hidden; margin-bottom: 8%; } /*******吹き出し:レスポンシブ:ここまで*******/ |
HTML
1 2 3 4 |
<div id="wrapper"> <div class="question_Box"> <div class="question_image"><img src="/img/takeru_smile-L.png" /><br>タケル</div> <div class="arrow_question_takeru">ここに会話を入れます。</div></div></div> |
HTMLは、こんな感じです。
で、・・・
これを表示させてみると、・・・

タケル
はい!
このように表示されます。
もちろん、レスポンシブル対応です。
会話形式の場合には、同一のHTMLを何回も使用しますので、別途、「Post Snippets」プラグインを利用します。
会話形式の吹き出しバブルで、記事を書く時には、何度も、何度も、同じHTMLを書かなければいけません。
その都度、同じHTMLを記述することは、現実的とは言えませんよね。
そこで、利用したいのが、・・・
「Post Snippets」です。
長いHTMLをショートコードとして登録して利用します。
こちらの詳細は、こちらで、記事にしています。
宜しければ、お読みください。
非常に、便利なプラグインです。
これからは、Wordpressなども含めて、このような画像による「会話形式」の
ブログが多数出現してくると予想されます。
あなたも、この記事を参考に、ご自分のブログに採用されてみてはどうでしょうか?