<html> <head> <meta charset="utf-8"> <title>Heart_Beat_GIFT</title> <link rel="stylesheet" href="./reset.css"> <link rel="stylesheet" href="./base.css"> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/jquery.slick/1.6.0/slick.css"> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/jquery.slick/1.6.0/slick-theme.css"> <link rel="stylesheet" href="./common.css"> <link rel="stylesheet" href="./top.css"> <link rel="stylesheet" href="./sample.css"> </head> <body> <main> <article class="side_length"> <div class="side_length_limit"> <h1></h1> <ul class="top_gyarally_container"> <li> </li> <li> </li> <!-- <div>abc</div> --> <li> </li> <li> </li> </ul> </div> </article> </main>> </body> </html> コード
li{ list-style: none; } .top_gyarally_container { display: flex; flex-wrap: wrap; justify-content: space-between; padding: 0px 16px 0px 16px; } .top_gyarally_container li{ width: 260px; height: 260px; background-repeat: no-repeat; background-position: 50% 50%; background-size: contain; /* background -color: black; */ background-color: #330033; margin-top: 24px } .top_gyarally_container li:nth-child(1){ background-image: url('https://placehold.jp/150x150.png'); } .top_gyarally_container li:nth-child(2){ background-image: url('https://placehold.jp/150x150.png'); } .top_gyarally_container li:nth-child(2):after{ content: "abc"; display: block; color: red; } コード
上記の背景画像にあてた疑似要素のafterなのですが、私の想定では四角形の真下に表示されるはずでした。。
しかしなぜか背景画像の左上に重なって文字が表示されています。
liにきっちりと幅と高さを持たせているので、普通は勝手に重なったりしないと思ったのですが、これはどういうことなのでしょうか。
疑似要素の仕様で重なるようになっているのでしょうか。
それとなのですが、beforeに変えてもafterと同じ表示結果でした。
これも意味がわからないのですが仕組みを教えていただけないでしょうか。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/18 02:05