メディアクエリを利用して、添付①のような形を実現したいのですが、添付②のようにGoodafternoonの文字の周りだけしか色が付きません。
全ての背景に色を適用するにはどのようにすればよいでしょうか?
以下記載したCSS
.w-50 { width: 50%; } .d-flex { display:flex; } .direction-column { flex-direction: column; } .align-items-center { align-items: center; } .text-center { text-align: center; } .bg-blue { background: #74b9ff; } .bg-red { background: #fab1a0; } @media (min-width: 768px) and (max-width:992px) { .morning { width:500px; } } @media (min-wdth:992px){ .morning{ width:30%; } } @media (min-width: 768px) and (max-width:992px) { .afternoon { background:#55efc4; } } @media(min-width:992px){ .afternoon{ background: #bdc3c7; } }
以下記載したHTMLリンク内容
<div class="d-flex direction-column align-items-center"> <div class="bg-blue text-center"> <p>Hello</p> </div> <div class="bg-blue text-center w-50"> <p>Recursion</p> </div> <br> <div class="bg-red text-center"> <p class="morning">Good Morning</p> </div> <br> <div class="bg-red text-center"> <p class="afternoon">Good afternoon</p> </div> </div>
一番最後の閉じ波括弧が全角ですけど・・・