CSSがうまく適用されません。
CSSがうまく適用されないので、もう1つアプリを作成しまし他のですが、後に作った方は上手く動きました。
全く同じ、処理を行いましたが、前に作ったアプリはCSSが適用されていないという状態になりました。
(この後、どちらにもコピペしましたが、後の方は動きますが、前に作ったものはうまく動きませんでした。)
何故でしょう?全く原因がわかりませんでした。
いじったところ
stylesheet
application.css
setting.scss
style.scss
tweets.css.scss
Application.html.erb
以上を(相互に)コピペしてみたのですが、
前に作った方はうまく動きませんでした。
以下は、application.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 any plugin's vendor/assets/stylesheets directory 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 bottom of the * compiled file so the styles you add here take precedence over styles defined in any styles * defined in the other CSS/SCSS files in this directory. It is generally better to create a new * file per style scope. * *= require_tree . *= require_self */
おそらく、CSSの問題なのでapplicationが怪しいと思うのですが原因が全く分かりません。
失敗作 画像
追記
application.html.erb
<!DOCTYPE html> <html> <head> <title>Pictweet</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> <script type="text/javascript"> WebFontConfig = { google: { families: [ 'Unica+One::latin' ] } }; (function() { var wf = document.createElement('script'); wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; wf.type = 'text/javascript'; wf.async = 'true'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wf, s); })(); </script> </head> <body> <header class="header"> <div class="header__bar row"> <h1 class="grid-6"><a href="/">Pic</a></h1> <% if user_signed_in? %> <div class="user_nav grid-6"> <%= link_to "ログアウト",destroy_user_session_path,method: :delete %> <a class="post" href="/tweets/new">投稿する</a> </div> <% else %> <div class="grid-6"> <%= link_to "ログイン",new_user_session_path, class: 'post'%> <%= link_to "新規登録",new_user_registration_path,class: 'post'%> </div> <% end %> </div> </header> <%= yield %> <footer> <p> Copyright PicTweet 2014. </p> </footer> </body> </html>
一応、ブラウザのキャッシュは削除してみましたが治りませんでした。
ページを検証しても、
<div class="content_post" style="background-image: url(https://cdn.pixabay.com/photo/2018/05/30/00/24/thunderstorm-3440450_960_720.jpg);"> <p>sasaas</p> <span class="name">kokok</span> </div>
特に問題はなさそうに見えました。
回答1件
あなたの回答
tips
プレビュー