html - Pseudo element goes on top and not on the bottom of element -


i have :after pseudo element create border bottom animation (border coming in left right), used technique several times time border comes on top , not on bottom reason, cant figure out. tried using float , chaning display type makes no different.

html:

  <div class="search">      <svg viewbox="0 0 485.213 485.213">              <path d="m471.882,407.567l360.567,296.243c-16.586,25.795-38.536,47.734-64.331,64.321l111.324,111.324                 c17.772,17.768,46.587,17.768,64.321,0c489.654,454.149,489.654,425.334,471.882,407.567z"/>             <path d="m363.909,181.955c363.909,81.473,282.44,0,181.956,0c81.474,0,0.001,81.473,0.001,181.955s81.473,181.951,181.955,181.951                 c282.44,363.906,363.909,282.437,363.909,181.955z m181.956,318.416c-75.252,0-136.465-61.208-136.465-136.46                 c0-75.252,61.213-136.465,136.465-136.465c75.25,0,136.468,61.213,136.468,136.465                 c318.424,257.208,257.206,318.416,181.956,318.416z"/>             <path d="m75.817,181.955h30.322c0-41.803,34.014-75.814,75.816-75.814v75.816c123.438,75.816,75.817,123.437,75.817,181.955z"/>      </svg>      <span>zoeken</span>    </div> 

css:

.search {   transition: 0.5s ease;   border-bottom: 2px solid transparent;   white-space: nowrap;   width: 120px;   height: 60px;   float: left;   display: block; }  .search:after {   content: '';   display: block;   height: 2px;   width: 0;   background: $main-color;   transition: width .5s ease, background-color .5s ease;   float: none; }  .search:hover:after {   width: 100%; } 

visual of problem

here visual of problem. red line should on botttom.

in these cases use position: absolute

.search {    white-space: nowrap;    width: 120px;    height: 60px;    position: relative;  }  .search svg {    height: 100%;  }  .search:after {    content: '';    position: absolute;    left: 0;    bottom: -4px;    height: 2px;    width: 0;    background: red;    transition: width .5s ease;  }  .search:hover:after {    width: 100%;  }
<div class="search">      <svg viewbox="0 0 485.213 485.213">              <path d="m471.882,407.567l360.567,296.243c-16.586,25.795-38.536,47.734-64.331,64.321l111.324,111.324                  c17.772,17.768,46.587,17.768,64.321,0c489.654,454.149,489.654,425.334,471.882,407.567z"/>              <path d="m363.909,181.955c363.909,81.473,282.44,0,181.956,0c81.474,0,0.001,81.473,0.001,181.955s81.473,181.951,181.955,181.951                  c282.44,363.906,363.909,282.437,363.909,181.955z m181.956,318.416c-75.252,0-136.465-61.208-136.465-136.46                  c0-75.252,61.213-136.465,136.465-136.465c75.25,0,136.468,61.213,136.468,136.465                  c318.424,257.208,257.206,318.416,181.956,318.416z"/>              <path d="m75.817,181.955h30.322c0-41.803,34.014-75.814,75.816-75.814v75.816c123.438,75.816,75.817,123.437,75.817,181.955z"/>      </svg>      <span>zoeken</span>    </div>


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -