• 카테고리

    질문 & 답변
  • 세부 분야

    웹 개발

  • 해결 여부

    미해결

.content:before 값에 z-index값을 줘도 뒤로 안가는 이유

22.09.21 16:26 작성 조회수 2.77k

1

글에 기울어진 디자인이 겹쳐서 이 디자인을 후순위로 하려고 z-index를 사용했는데 이게 동작을 안하네요.

 

왜 동작을 안하는지 알수 있을까요

답변 6

·

답변을 작성해보세요.

0

왜 마이너스 값을 줘야 작동을 하는건가요

숫자가 낮은게 무조건 후순위 아닌가요

낮은게 후순위 맞습니다. 1 보다 -1이 더 낮은거니까 후순위로 갑니다.
포지션 속성이 relative, absolute, fixed가 들어가면 기본적으로 z-index는 0이 부여됩니다.
그러니까 0보다 낮아야 하니까 마이너스 값을 줘야 뒤로 숨길 수 있습니다.

.content에 2를 주고 before에 1를 줬으면 똑같은거 아닌가요

0

z-index: 1 이렇게 주셨던데 마이너스 값으로 주세요.

image

0

/* Fontawesome 4.7 */
@import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
/* Google Web Fonts CDN */
@import url('https://fonts.googleapis.com/css?family=Noto+Sans+KR:300,400,500,700,900&display=swap');
/* Google Web Font */
@import url('https://fonts.googleapis.com/css?family=Raleway&display=swap');
body{
    font-family: 'Raleway', sans-serif;
    line-height: 1.5em;
    margin: 0;
    background-color: #fff;
}

.gallery{
    display: flex;
    list-style: none;
    height: 100vh;
    margin:0;
    padding:0;
}
.gallery li{
    border-right: 5px solid #000;
    flex:1;
    transition: 0.5s;
    position: relative;
    overflow: hidden;
}
.gallery li:last-child{
    border-right: none;
}
.gallery li:nth-child(1){
    background: url(images/artistic-image-01.jpg) no-repeat center center;
}
.gallery li:nth-child(2){
    background: url(images/artistic-image-02.jpg) no-repeat center center;
}
.gallery li:nth-child(3){
    background: url(images/artistic-image-03.jpg) no-repeat center center;
}
.gallery li:nth-child(4){
    background: url(images/artistic-image-04.jpg) no-repeat center center;
}
.gallery li:nth-child(5){
    background: url(images/artistic-image-05.jpg) no-repeat center center;
}
.gallery:hover li {
}
.gallery li:hover{
    flex:3;
    filter: grayscale();
}
.content {
    position:absolute;
    background-color: #000;
    color: #fff;
    height: 200px;
    bottom:-200px;
    transition: 0.5s;
    text-align: center;
    z-index: 2;
}
.gallery li:hover .content{
    bottom: 0;
    transition-delay: 0.5s;
}
.content:before{
    content: '';
    position: absolute;
    background-color: red;
    width: 100%;
    height: 100px;
    left:0;
    top:-60px;
    transform: rotate(-10deg) scale(1.5);
    z-index: 1;
}

 <ul class="gallery">
        <li>
            <div class="content">
                <h1>Uploads made easy</h1>
                <p>Use Spotify for Artists to upload your releases. With previews and simple edits, you can control exactly how your music appears to divsteners.
                </p>
                <div class="sns">
                    <a href="#none"><i class="fa fa-facebook-square"></i></a>
                    <a href="#none"><i class="fa fa-instagram"></i></a>
                    <a href="#none"><i class="fa fa-linkedin-square"></i></a>
                    <a href="#none"><i class="fa fa-google-plus-square"></i></a>
                </div>
                <div class="box"></div>
            </div>
        </li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>

0

부분적으로 코드를 올리지 마시고 캡쳐가 아니고 html css 코드 모드를 복사해서 올려주세요.

0

20220921180410.png

0

html css 코드를 복사해서 올려주세요.
그럼 제가 확인을 빨리 할 수 있습ㄴ디ㅏ.