How can using CSS or JS make a transform without touching the text?
Like now:
&:hover transform: rotate(0deg) scale(1.001) skew(-12deg) translate(0px) background: #fff text-decoration: none How can using CSS or JS make a transform without touching the text?
Like now:
&:hover transform: rotate(0deg) scale(1.001) skew(-12deg) translate(0px) background: #fff text-decoration: none If without affecting the text, then with the help of pseudo-elements: before or: after
&:after { content: ''; display: block; position: absolute; top: 0; left: 0; right: 0; bottom: 0; transition: all .27s ease-in-out; transform: rotate(0deg) scale(1.001) skew(-12deg) translate(0px); background: #fff; z-index: 5; opacity: 0; } C help jquery:
$(function() { $(".item").hover( function() { $(this).css({ transform: "rotate(0deg) scale(1.001) skew(-12deg) translate(0px)", background: "#fff" }) $(this).children('p').css({ transform: "rotate(0deg) scale(1.001) skew(12deg) translate(0px)" }) }, function() { $(this).css({ transform: "rotate(0deg) scale(1.001) skew(0deg) translate(0px)", background: "none" }) $(this).children('p').css({ transform: "rotate(0deg) scale(1.001) skew(0deg) translate(0px)" }) } ) }); .parent { background-color: #fcc01f; list-style-type: none; padding-left: 50px; } .item { padding: 10px; text-align: center; display: inline-block; text-transform: uppercase; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul class="parent"> <li class="item"> <p>text 1</p> </li> <li class="item"> <p>text 2</p> </li> <li class="item"> <p>text 3</p> </li> </ul> css :) explain why you use jquery for hover ? - MasterAlexYou can do this by adding a reverse skew to the text so that it is even. Added a little jquery, but only so that you can click on the menu items in the example.
$(document).ready(function() { $('.nav-list').on('click', '.nav-item', function() { $('.nav-item').removeClass('active'); $(this).addClass('active'); }); }); body { background: #232423; } .nav-list { list-style-type: none; padding: 0; margin: 0; text-align: center; background: #fcc01f; } .nav-list .nav-item { display: inline-block; vertical-align: middle; position: relative; margin-left: -5px; } .nav-list .nav-item.active { transform: rotate(0deg) scale(1.001) skew(-12deg) translate(0px); background: #fff; } .nav-list .nav-item .nav-link { text-transform: uppercase; color: #111; text-decoration: none; display: block; padding: 1.2rem; font-family: sans-serif; font-weight: bold; position: relative; z-index: 10; } .nav-list .nav-item.active .nav-link { transform: skew(12deg); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul class="nav-list"> <li class="nav-item active"><a href="#" class="nav-link">главная</a> </li> <li class="nav-item"><a href="#" class="nav-link">о нас</a> </li> <li class="nav-item"><a href="#" class="nav-link">цены</a> </li> </ul> .parent { background-color: #fcc01f; list-style-type: none; padding-left: 50px; } .item { padding: 10px; text-align: center; display: inline-block; text-transform: uppercase; transform: rotate(0deg) scale(1.001) skew(-12deg) translate(0px); cursor: pointer; } .item:hover { background-color: #fff; } .item p{ transform: rotate(0deg) scale(1.001) skew(12deg) translate(0px); } <ul class="parent"> <li class="item"> <p>text 1</p> </li> <li class="item"> <p>text 2</p> </li> <li class="item"> <p>text 3</p> </li> </ul> Source: https://ru.stackoverflow.com/questions/534379/
All Articles