javascript - Button not animating from center -
so when used jquery animate padding instead of animation if anchor point center animates top left. code , jsfiddle link down below.
html:
<div id="gaming-news-info"> <a id="news-button" style="cursor:pointer;">go news section</a> </div>
css:
#gaming-news-info { position: absolute; z-index: 999; width: 400px; height: 200px; top: 50%; left: 50%; transform: translatex(-50%) translatey(-50%); margin-top: -100px; } #news-button { background-color: #4caf50; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; position: absolute; margin-top: 130px; font-family: "prompt-semibold"; margin-left: 90px; }
you not need jquery/javascript simple hover effect. css3 transitions , transformations capable of doing same thing without overhead of script library....
#gaming-news-info { position: absolute; z-index: 999; width: 400px; height: 200px; top: 50%; left: 50%; transform: translatex(-50%) translatey(-50%); margin-top: -100px; } #news-button { background-color: #4caf50; border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; position: absolute; margin-top: 130px; font-family: "prompt-semibold"; margin-left: 90px; transform: scale(1); transition: .2s; } #news-button:hover { transform: scale(1.05); transition: .2s; }
<div id="gaming-news-info"> <a id="news-button" style="cursor:pointer;">go news section</a> </div>
Comments
Post a Comment