Elise__ Posted July 16, 2021 Share Posted July 16, 2021 Site URL: https://mandarin-violin-mjw7.squarespace.com Dear Squarespace community, For my site I wish to have an animated underline that differs for Mobile and Desktop. For Mobile I would like an underline that goes from left to right on hover. For Desktop I would like an underline that goes outwards from the centre. https://mandarin-violin-mjw7.squarespace.com/config/ the password is: elise Does someone have css code to realize this? Warmly, Elise Link to comment
tuanphan Posted July 18, 2021 Share Posted July 18, 2021 Try adding to Design > Custom CSS /* link hover */ .header-nav-item { a { text-decoration: none !important; background-image: none !important; position: relative; } a:after { content: ""; background: currentColor; height: 1px; width: 100%; display: inline-block; position: absolute; bottom: 0; right: 0; -webkit-transition: all 0.3s; -o-transition: all 0.3s; transition: all 0.3s; } a:hover:after { width: 0; -webkit-transition: all 0.3s; -o-transition: all 0.3s; transition: all 0.3s; } } Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
Elise__ Posted July 18, 2021 Author Share Posted July 18, 2021 (edited) On 7/18/2021 at 2:28 AM, tuanphan said: Try adding to Design > Custom CSS /* link hover */ .header-nav-item { a { text-decoration: none !important; background-image: none !important; position: relative; } a:after { content: ""; background: currentColor; height: 1px; width: 100%; display: inline-block; position: absolute; bottom: 0; right: 0; -webkit-transition: all 0.3s; -o-transition: all 0.3s; transition: all 0.3s; } a:hover:after { width: 0; -webkit-transition: all 0.3s; -o-transition: all 0.3s; transition: all 0.3s; } } Dear @tuanphan, Thank you for your reply 🙂 I tried your code, however the effect is not what I had in mind . I managed to come close with the code below (see also my site). However I still face two problems; 1. The underline under the navigation is quite far from the title. How do I decrease this distance so that the underline is directly under the title ? 2. For the mobile navigation, the animation takes the entire mobile screen. How can I adjust it so that it only underlines the title? /* navigation underline animation */ .header-nav-item::after { content: ''; background: #FFFFFF; //color height: 2px; //thickness width: 0; display: block; margin-top: 0px !important; transition: width 0.5s; //animation speed margin: 0 auto; } .header-nav-item:hover::after { width: 100%; } .header-nav-item--active a { background-image: none !important; } /* mobile navigation underline animation */ .header-menu-nav-item::after { content: ''; background: #FFFFFF; //color height: 2px; //thickness width: 0; display: block; margin-top: 5px !important; transition: width 0.5s; //animation speed margin: 0.6 auto; } .header-menu-nav-item:hover::after { width: 100%; } .header-menu-nav-item--active a { background-image: none !important; } Edited July 19, 2021 by Elise__ Najiyya 1 Link to comment
tuanphan Posted July 20, 2021 Share Posted July 20, 2021 @media screen and (max-width:767px) { .header-menu-nav-item:hover::after { width: 50%; } } Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment