Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda