Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Menú desplegable saliendo del encabezado para RTL

He usado el siguiente código jQuery para detener el menú desplegable que sale del encabezado. y funciona bien en la versión LTR normal.

pero quiero una solución para la versión RTL. ¿Cómo puedo hacerlo?

jQuery

 $('.primary-menu .dropdown-menu').each(function() { var menu = $('#header .header-row').offset(); var dropdown = $(this).parent().offset(); var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#header .header-row').outerWidth()); if (i > 0) { $(this).css('margin-left', '-' + (i) + 'px'); } });

HTML

 <header id="header"> <div class="container"> <div class="header-row"> <div class="header-column justify-content-start"> <div class="logo me-3"> ..... </div> <!-- Primary Navigation ============================== --> <nav class="primary-menu navbar navbar-expand-lg"> <div id="header-nav" class="collapse navbar-collapse"> <ul class="navbar-nav me-auto"> <li><a href="#">Link</a></li> <li><a href="#">Link 2</a></li> <li class="dropdown dropdown-mega"> <a class="dropdown-toggle" href="#">Pages</a> <ul class="dropdown-menu"> <li> <div class="dropdown-mega-content"> ........ </div> </li> </ul> </li> </ul> </div> </nav> <!-- Primary Navigation end --> </div> </div> </div>

He intentado debajo de algo, pero esto no funciona.

 $('.primary-menu .dropdown-menu').each(function() { var menu = $('#header .header-row').offset(); var dropdown = $(this).parent().offset(); var i = (dropdown.right + $(this).outerWidth()) - (menu.right + $('#header .header-row').outerWidth()); if (i > 0) { $(this).css('margin-right', '-' + (i) + 'px'); } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El desplazamiento a la derecha es: window's width - ( element left offset + element outer width)

Entonces, he encontrado la solución final:

 $('.primary-menu .dropdown-menu').each(function() { var menu = $('#header .header-row').offset(); var dropdown = $(this).parent().offset(); var rightMenu = ($(window).width() - (menu.left + $('#header .header-row').outerWidth())); var rightDropdown = ($(window).width() - (dropdown.left + $(this).parent().outerWidth())); var i = (rightDropdown + $(this).outerWidth()) - (rightMenu + $('#header .header-row').outerWidth()); if (i > 0) { $(this).css('margin-right', '-' + (i) + 'px'); } });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!