html - Transform scale on anchor elements not working in flexbox -
i using flexbox navigation bar @ top of page. have included code part because project entire site. anchor tags on site styled same, same transform: scale(1.2)
characteristic on hover. works everywhere except in nav. nothing seems scale @ inside of nav.
additionally on codepen, flexbox doesn't seem respect justify-content: space-around
, making anchors appear more squished on actual site.
codepen: https://codepen.io/colesam/pen/yxlpvw
a { color: #646c84; font-weight: 500; line-height: 1.7vw; transition: 0.2s; } a:hover { color: #ffaf54; cursor: pointer; transform: scale(1.2); text-decoration: none; } a:focus { color: #646c84; text-decoration: none; } a:focus:hover { color: #ffaf54; cursor: pointer; } .active-indicator { background: #ffaf54; border-radius: 25px; height: 2px; margin-top: -2px; margin-bottom: 5px; margin-left: auto; margin-right: auto; opacity: 0; transition: 0.2s; width: 25px; } .active-indicator.active { opacity: 1; } #menu { background: whitesmoke; border: 1px solid rgba(0, 0, 0, 0.1); display: flex; flex-direction: row; justify-content: space-around; padding: 0 25vw; position: fixed; left: -1; right: -1; top: 0; transition: 0.2s; z-index: 1; } #menu { font-size: 0.9vw; } #menu.inactive { opacity: 0; }
<div id="menu"> <div id="landing-nav"> <a>home</a> <div class="active-indicator active"></div> </div> <div id="about-nav"> <a>about</a> <div class="active-indicator"></div> </div> <div id="portfolio-nav"> <a>portfolio</a> <div class="active-indicator"></div> </div> <div id="resume-nav"> <a>resume</a> <div class="active-indicator"></div> </div> <div id="contact-nav"> <a>contact</a> <div class="active-indicator"></div> </div> </div>
your nav menu has no width, flex items packed together.
yes, create illusion of width with:
#menu { padding: 0 25vw; }
but adds padding left , right of container. items still packed together, , justify-content
has no space work.
- revised codepen (padding removed)
instead of padding, try using width: 50vw
.
- revised codepen (padding removed; width added)
the problem transform: scale()
have applied inline-level element (a
), not transformable element.
either add display: block
anchor elements, or apply transform parent div.
- revised codepen (padding removed; width added; added
display: block
a
elements)
references:
wiki
Comments
Post a Comment