skip to Main Content

Html – Automatic font size – js

How do you make font size automatically adjust so that the text doesn't overflow? const h1 = document.getElementsByTagName('h1')[0]; const content = document.getElementById('content'); let size = parseInt(window.getComputedStyle(h1).getPropertyValue('font-size')); while (checkIfOverflows(h1, content)){ size--; h1.style.fontSize = size + 'px'; } function checkIfOverflows(element, parent){ const…

VIEW QUESTION

Html – Conditional sibling selector in CSS?

I have a <ul> with children <li>. All of the <li> are siblings. I need them all to be siblings so that htmx.takeClass(); works to highlight the active item. My layout is like this: <ul class="list-group list-group-flush" hx-on:click="if (event.target.classList.contains('list-group-item')) htmx.takeClass(event.target,…

VIEW QUESTION

Html – Apply CSS style depending of tbody height

I have simple example that applies style when div height is less than 400px. <html> <head> <style> .card-container { container-type: size; container-name: sidebar; } .card-container { background: #ffe4e8; width: 200px; height: 100px; } @container sidebar (max-height: 400px) { .card-container div:first-child…

VIEW QUESTION

Html – image loading on chrome but not safari

I am new to coding and finished this project for freecodecamp. For some reason my logo will load on chrome but not on safari. Any ideas why? const checkButton = document.getElementById('check-btn') ; const userInput = document.getElementById('text-input'); const result = document.getElementById('result');…

VIEW QUESTION
Back To Top
Search