html - CSS title code animation -
info: css code showing name small line below , 1 hover on it, line starts completing full rectangle. when hover out, transitions being line below name.
the issue having that, when try changing size of text (in rectangle), have ton of issues such as: - rectangle needs adjusting new text height , width - rectangle needs re-centring (for reason not stay centred) - when text name: e.g. john smith, when size big, bottom of john, start touching top of smith
question: how can make code bit better, such when change size of text, fits automatically without ton of re-adjustments?
html code
<header id="header"> <div class="svg-wrapper"> <svg class="svg-name" xmlns="http://www.w3.org/2000/svg"> <rect class="shape" /> <div class="text">john smith</div> </svg> </div> </header>
css code
header { height: 450px; background-image: url(/assets/img/logo.svg), url(/assets/img/background.jpe); background-position: 20px 20px, bottom; } header nav { float: right; margin: 30px 30px 0 0; } header nav { display: inline-block; margin-left: 20px; color: rgba(0, 0, 0, 0.7); } header nav a:hover { color: black; } header .svg-wrapper { position: relative; top: 50%; transform: translatey(-50%); margin: 0 auto; width: 360px; } header .svg-wrapper:hover .shape { stroke-width: 2px; stroke-dashoffset: 0; stroke-dasharray: 960; } header .svg-name { height: 120px; width: 360px; } header .shape { height: 120px; width: 360px; stroke-dasharray: 140 940; stroke-dashoffset: -674; stroke-width: 8px; fill: transparent; stroke: black; border-bottom: 5px solid black; transition: stroke-width 1s, stroke-dashoffset 1s, stroke-dasharray 1s; } header .text { text-transform: uppercase; font-size: 132px; line-height: 32px; letter-spacing: 8px; color: black; top: -100px; position: relative; text-align: center; }
fiddle url
https://jsfiddle.net/snenkov/kshawbg5/6/
codepen url
change line height to
header .text { line-height:1; }
or remove line height "header .text" class.
Comments
Post a Comment