html - CSS transitioning child when parent is in hover state -


i trying move each letter in h1 heading specific new position whenever h1 element in 'hover' state. point reveal anagram 'chaser' 'search'

currently when mouse hovers on heading, of letters move correct place, without kind of transition.

h1 {    text-align:left;    font-family:'ubuntu mono', monospace;    font-size: 8vw;    font-weight:400;    margin:3vw 0;  }    .mover span {    position:relative;    -webkit-transition: .5s right ease;    transition: .5s right ease;  }    .mover:hover #c {    left:16vw;  }    .mover:hover #h {    left:16vw;  }    .mover:hover #s {    right:12vw;  }    .mover:hover #e {    right:12vw;  }       .mover:hover #r{    right:8vw;  }
<h1 class="mover">    <span id="c">c</span>    <span id="h">h</span>    <span id="a">a</span>    <span id="s">s</span>    <span id="e">e</span>    <span id="r">r</span>  </h1>

if explain why defunct, , if desired effect/interactivity possible css appreciated.

in order css transition work, need have both before , after property set. if want #c move 0 16vw, need set initial location 0 on non-hover state and new location of 16vw on hover state.

showing here:

h1 {      text-align: left;      font-family: 'ubuntu mono', monospace;      font-size: 8vw;      font-weight: 400;      margin: 3vw 0;  }    .mover span {      position: relative;      -webkit-transition: .5s right ease, .5s left ease;      transition: .5s right ease, .5s left ease;  }    #c, #h {      left: 0;  }    #s, #e, #r {      right: 0;  }    .mover:hover #c {      left: 16vw;  }    .mover:hover #h {      left: 16vw;  }    .mover:hover #s {      right: 12vw;  }    .mover:hover #e {      right: 12vw;  }       .mover:hover #r {      right: 8vw;  }
<h1 class="mover">      <span id="c">c</span>      <span id="h">h</span>      <span id="a">a</span>      <span id="s">s</span>      <span id="e">e</span>      <span id="r">r</span>  </h1>

you need specify transition both left , right properties.

note can't set both initial properties on span definition because 1 or other take precedence (depending on text direction).


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -