Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
Add marquee dynamically

I am trying to add a marquee to my HTML dynamically. This is the function I have created

                var element = document.getElementById('overflow');
                var parentElement = document.getElementById('countheader');
                if (element) {
                    var overflow = isElementOverflowing(element, parentElement);
                    if (overflow && !element.classList.contains('marquee')) {
                        element.className += "marquee";
                    } else if (!overflow) {
                        element.classList.remove('marquee');
                    }
                }

function isElementOverflowing(element, parentElement) {
        return parentElement.clientWidth <= element.clientWidth;
    }

In the CSS file I have the styling as

 #countheader{   
        background-color: #e9df8b;
        width: fit-content;
        white-space: nowrap;
        min-width: 100%;
        overflow: hidden;
        padding-left: 11px!important;
        max-width: 1266px!important;
    }
    #overflow{
        max-width: 1266px!important;
    }

#HTML

 <div class="page-content" style="background-color: {{isDarkMode ? '#000000' : '#FFFFFF'}}">

                    <!-- Item Count Card-->

                    <div class="order-card item-card"
                         ng-if="currentStation.get('enableItemCount') && viewTitle === 'Open Orders' && currentStation.get('itemCountFilters').length > 0 && itemsCount.length > 0">
                       
                        <div class="card-header"  id="countheader">
                                <div id="overflow">
                                    <b class="item-heading">Total Count</b>
                                    <span  class="item-count" ng-repeat="item in itemsCount">{{item.name}}({{item.quantity}})</span>
                                </div>
                        </div> 
                    </div>
                    <!-- Item Count Card -->

But in some cases, I am seeing that the text overflows the parent div in the UI but in the function isOverflowing it is still showing parent element width greater and so the marquee does not gets added in the class. Is there a better way to find the height of the parent div and child div content?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda