0

First. Sorry to lack English grammar skills. I trying clone coding one of korea corporation website. but, is not working. transition property of Pseudo-element. The css line number in question is "51". in header .gnb ul li a span:hover:after

/* Skip css reset and import img file */
/* index.css */ 

header{
    width: 100%;
    height: 80px;
    text-align: center;
}

header h1{
    position: absolute;
    left: 50px; 
    top: 0;
}

header h1 a {
    display: block;
    width: 110px;
    height: 50px;
    position: absolute;
    top: 15px;
    background: url("../img/sp_com.png") no-repeat -300px 0;
    color: transparent;
}

header .gnb ul li{
    display: inline-block;
}

header .gnb ul li a{
    display: block;
    height: 80px;
    padding: 0 35px;
    font-size: 17px;
    line-height: 80px;
}

header .gnb ul li a span{
    position: relative;
}

header .gnb ul li a span:hover:after{
    content: "";
    display: block;
    position: absolute;
    left: 0;
    bottom: -10px;
    width: 100%;
    height: 1px;
    background-color: #336584;
    **transition: all 1s ease;**
}

header .spot{
    position: absolute;
    right: 50px;
    top: 0;
}

header .spot ul li{
    float: left;
    line-height: 80px;
}

header .spot ul li a{
    display: block;
    position: relative;
    height: 80px;
    padding: 0 10px;
    line-height: 80px;
}

header .spot ul li:last-child a{
    padding-right: 0;
}

header .spot ul li:before{
    content:"";
    display: block;
    position: absolute;
    top: 50%;
    width: 1px;
    height: 7px;
    background-color: #ccc;
    transform: translateY(-50%)
}

header .spot ul li:first-child:before{
    content: "";
    display: none;
}

header .gnb ul li a:hover{
    font-weight: blod !important;
    color:#336584;
}

header .spot ul li a:hover{
    font-weight: bold !important;
    color:#336584;
    text-decoration: underline;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../css/default.css">
    <link rel="stylesheet" href="../css/index.css">
    <title>Document</title>
</head>

<body>
    <header>
        <h1><a href="#">한솔홈데코</a></h1>
        <h2 class="hide">대메뉴</h2>
        <nav class="gnb">
            <ul>
                <li><a href="#1"><span>제품정보</span></a></li>
                <li><a href="#2"><span>시공사례</span></a></li>
                <li><a href="#3"><span>고객센터</span></a></li>
                <li><a href="#4"><span>기업소개</span></a></li>
                <li><a href="#5"><span>사업분야</span></a></li>
            </ul>
        </nav>
        <h2 class="hide">관련서비스</h2>
        <nav class="spot">
            <ul>
                <li><a href="#6">제품찾기</a></li>
                <li><a href="#7">SITEMAP</a></li>
                <li><a href="#8">BLOG</a></li>
                <li><a href="#9">YOUTUBE</a></li>
            </ul>
        </nav>
    </header>
</body>

</html>
iampkiron
  • 21
  • 2

2 Answers2

0

Add transition property in spna:after to get transition effect in hover

Try using this code:

header .gnb ul li a span:after{
  content: "";
  transition: all 0.4s ease;
}

/* Skip css reset and import img file */
/* index.css */ 

header{
    width: 100%;
    height: 80px;
    text-align: center;
}

header h1{
    position: absolute;
    left: 50px; 
    top: 0;
}

header h1 a {
    display: block;
    width: 110px;
    height: 50px;
    position: absolute;
    top: 15px;
    background: url("../img/sp_com.png") no-repeat -300px 0;
    color: transparent;
}

header .gnb ul li{
    display: inline-block;
}

header .gnb ul li a{
    display: block;
    height: 80px;
    padding: 0 35px;
    font-size: 17px;
    line-height: 80px;
}

header .gnb ul li a span{
    position: relative;
}
header .gnb ul li a span:after {
  content: "";
  transition: all 0.4s ease;  
}
header .gnb ul li a span:hover:after{   
    display: block;
    position: absolute;
    left: 0;
    bottom: -10px;
    width: 100%;
    height: 1px;
    background-color: #336584;
}

header .spot{
    position: absolute;
    right: 50px;
    top: 0;
}

header .spot ul li{
    float: left;
    line-height: 80px;
}

header .spot ul li a{
    display: block;
    position: relative;
    height: 80px;
    padding: 0 10px;
    line-height: 80px;
}

header .spot ul li:last-child a{
    padding-right: 0;
}

header .spot ul li:before{
    content:"";
    display: block;
    position: absolute;
    top: 50%;
    width: 1px;
    height: 7px;
    background-color: #ccc;
    transform: translateY(-50%)
}

header .spot ul li:first-child:before{
    content: "";
    display: none;
}

header .gnb ul li a:hover{
    font-weight: blod !important;
    color:#336584;
}

header .spot ul li a:hover{
    font-weight: bold !important;
    color:#336584;
    text-decoration: underline;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../css/default.css">
    <link rel="stylesheet" href="../css/index.css">
    <title>Document</title>
</head>

<body>
    <header>
        <h1><a href="#">한솔홈데코</a></h1>
        <h2 class="hide">대메뉴</h2>
        <nav class="gnb">
            <ul>
                <li><a href="#1"><span>제품정보</span></a></li>
                <li><a href="#2"><span>시공사례</span></a></li>
                <li><a href="#3"><span>고객센터</span></a></li>
                <li><a href="#4"><span>기업소개</span></a></li>
                <li><a href="#5"><span>사업분야</span></a></li>
            </ul>
        </nav>
        <h2 class="hide">관련서비스</h2>
        <nav class="spot">
            <ul>
                <li><a href="#6">제품찾기</a></li>
                <li><a href="#7">SITEMAP</a></li>
                <li><a href="#8">BLOG</a></li>
                <li><a href="#9">YOUTUBE</a></li>
            </ul>
        </nav>
    </header>
</body>

</html>
Minal Chauhan
  • 6,025
  • 8
  • 21
  • 41
-1

transfer your transition property from header .gnb ul li a span:hover:after to header .gnb ul li a

header .gnb ul li a{
    display: block;
    height: 80px;
    padding: 0 35px;
    font-size: 17px;
    line-height: 80px;
    transition: all 1s ease;
}
BillJustin
  • 274
  • 1
  • 10