1. To align the left edge of the message with the right edge of the line, regardless of the length of the message: first position the message absolutely with right: 50px (since you want the icon to appear on the left), then apply a transform: translateX(100%) :
.card-item .control { position: absolute; right: 50px; transform: translateX(100%); }
2. To animate a message on hover: you need to define transition on .control , and then just transform: translateX(0) on :hover . Also, set right: 0 so that the right edge of the message is flush with the right edge of the line.
.card-item .control { position: absolute; right: 50px; transform: translateX(100%); transition: all 0.3s; } .card-item .control:hover { right: 0; transform: translateX(0); }
3. To vertically align the message text: since you have a fixed height for the message, set the line-height of the message text to the height line, which is 50px , and vertical-align: top :
.card-item .control .message { line-height: 50px; vertical-align: top; }
http://codepen.io/myajouri/full/jCBiH
source share