CSS :before :after 텍스트 겹치기 z-index

Jmnote bot (토론 | 기여)님의 2022년 5월 19일 (목) 02:07 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

CSS :before :after 텍스트 겹치기 z-index
  • z-index: -1;(암튼 음수)을 주면 content가 텍스트보다 뒤에 위치하게 된다.
  • 만약 배경색이 있으면(투명이 아니라면) 배경에 가려서 보이지 않게 된다.
<style>
  .box1:before {
    color: orange;
    content: "★";
    font-size: 3em;
    margin: -.6em 0 -1em 0;
    position: absolute;
  }

  .box2:before {
    color: skyblue;
    z-index: -1;
    content: "★";
    font-size: 3em;
    margin: -.6em 0 -1em 0;
    position: absolute;
  }

</style>

<div class='box1'>어쩌구</div>
<br><br>
<div class='box2'>어쩌구</div>

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}