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

145
Vistas
HTML/CSS Designing a responsive website. An onclick attribute won't function

I'm trying to create a responsive design for a practice website. The situation is that the below menu-icon image is only displayed while width is less than 701 px. So it does that fine. But the problem is that, when menu-icon image is displayed, screen width less than 701 px, I click on the image and nothing happens. The onclick attribute "togglemenu()" does not seem to function. Can someone help please? This is a live site:

https://moortje.github.io/HTML-CSS-Project-Bro-Code/

The menuList and menu-icon in question are at the very bottom.

Here is an HTML snippet.

<ul id="menuList">
    <li><a href="">CSI</a></li>
    <li><a href="">CHP</a></li>
    <li><a href="">HCSS</a></li>
    <li><a href="">JS</a></li>
</ul>
       
<img src="moortje2.png" class="menu-icon" onclick="togglemenu()">
    
<script type="text/javascript">
        
    var menuList = document.getElementById("menuList");
       
    menuList.style.maxHeight = "0px";
      
    function togglemenu(){
        
        if (menuList.style.maxHeight == "0px") {
            menuList.style.maxHeight = "130px";
        }

        else{
            menuList.style.maxHeight = "0px";
            }
    }
        
</script>

Here is a CSS snippet.

.menu-icon{
            width: 25px;
            cursor: pointer;
            display: none ;
           }

@media only screen and (max-width: 700px){
        .menu-icon{
            display: block;
        }
    
        #menuList{
            overflow: hidden;
            transition: 0.5s;
        }
}
about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

The problem is that you are setting max-height and max-width

Changing those properties doesn’t change the size of the element, only what its max bounds are.

Use width and height instead.

about 4 years ago · Santiago Trujillo Denunciar

0

It's appear at the top of the page because of position: absolute

about 4 years ago · Santiago Trujillo Denunciar

0

Well I went through the code and find out that togglemenu function is working properly and its even opening the menu. But you have given position absolute to ul tag and when you click on toggle image. It opens menu but at the top of page.

So click on image and scroll up to top and you will going to see your menu. You just have to adjust its position to open it below toggle menu button/image.

about 4 years ago · Santiago Trujillo Denunciar
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