Trouble with custom font causing text to be cut off in h1 and h2 sizes when window is

Update: After using a custom font "Gotham" in the @font-face, I encountered several bugs that seem to stem from this source. I'm unsure of how to resolve these issues while still retaining my custom font. Any suggestions?

Update #2: The problem was resolved by adding ascent-override: 80%; to the font-face. However, this solution does not work on Safari browsers. Is there an alternative fix available?

During testing of my website by resizing the browser window height, I noticed a horizontal invisible line cutting off my h1/h2 text. Research suggests it may be related to line-height, but I am uncertain.

Considerations:

  1. Without setting a line-height for h1/h2, their height renders as 0px and becomes invisible. Strangely, the p tag remains unaffected with or without a line-height specified. Why is this the case? see below, all line height removed

  2. When a line-height is defined, the text of h1/h2 appears offset from the container. When inspecting the h1 in devtools, the text aligns higher than the box, extending beyond the margins.

  3. Resizing the window causes the 'invisible line' intersecting the text to remain stationary, while the text moves along with the page adjustments. The page appears normal when the invisible line falls between lines of h1/h2 text.

  4. I have a script animating numbers by updating the innerHTML with the next number. Could the use of .innerHTML be causing an issue? During the animation, the invisible line intersects the numbers before correcting itself upon window resize.

  5. Could the font usage be a factor? My custom font, 'Gotham', is implemented through @font-face in the css.

I apologize for any confusion in my description, and I would appreciate any guidance on resolving this issue.

Answer №1

Instead of leaving a comment, I am providing an answer. Have you considered utilizing the box-sizing property to address this issue? https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

This approach should ensure that the h1/h2 elements stay within the designated box without getting cut off.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the best practices for utilizing CSS position (relative, absolute) combined with percentage dimensions for height and width?

There are numerous questions and answers related to this topic, but I have not come across a case like the one mentioned below. Everyone talks about setting the height and width in percentage by first setting the parent's height in percentage, but it ...

Tips for maintaining the current object's status while utilizing ngFor in Angular

The JSON data provided is structured as follows. [ { "route":"vehicle", "next-route":"driver", "isActive":false }, { "title":"Driver", "route":"driver ...

Encountered a SocketTimeoutException while trying to parse JSON data from a

Can someone assist me with parsing HTML using Jsoup from this specific URL on Sierra's clearance page for women's red items within a price range of $10 to $14.99: Whenever I attempt to parse the HTML from this URL, I encounter the following erro ...

Utilizing LESS for Mixing

I've been diving into the official LESS documentation (version 1.5) and I'm struggling to grasp how I can import a reference to another CSS file to utilize its content in my own stylesheet. For instance: stylesheet.less @import (reference) "boo ...

Error: Unable to access the 'prototype' property of an undefined object (inherits_browser.js)

After updating our app to a newer version of create-react-app, we started encountering the following error: https://i.sstatic.net/ILdsl.png This error seems to be related to inherits_browser.js, which is likely from an npm module that we are unable to id ...

PHP file upload error: Angular JS form submission issue

I am currently working on creating an upload method using Angular and PHP. Here is what I have come up with so far... HTML <form class="well" enctype="multipart/form-data"> <div class="form-group"> <label for ...

Browser Bing Parser

After successfully creating a web parser for Google search results, I decided to implement a similar parser for Bing. However, I encountered an error that I couldn't resolve. Below is the code snippet that caused the issue: var rows = htmlDoc.Documen ...

Is it possible for me to create a menu using the .row and .col classes from Bootstrap?

I attempted to create a menu using Bootstrap's cols. Something similar to this: https://i.stack.imgur.com/55xst.png However, I faced numerous challenges when trying to implement it into Wordpress and realized that it may not be the best approach... ...

What are the benefits of adding member functions to the data structures of React.js store?

Using React.js and Typescript, I store plain Javascript objects in the React.js store. These objects are sometimes received from the server without any member functions, but I wish to add functions for better organization. Instead of having to rely on exte ...

Validate input strings in Node.js using Joi to detect and return an error if there are leading or trailing spaces

Looking to set up JOI validation in Node.js that flags errors if a string begins or ends with an empty space. For example: name = "test123" //valid name = "test(space)" or "(space)test" // invalid ...

Various image dimensions cause divs to shift unevenly

Here is the current setup: <div class="row"> <div class="col-md-4 content-column"> <img class="btn-center btn-desktop" src="images/buttons/btn-desktop.svg" alt="desktop button"> <h2 class="btn-deskt ...

Web browser displaying vertical scroll bars centered on the page

I'm new to HTML and have been experimenting with this CSS file to center my form. I've managed to get it working, but the issue now is that it's causing scroll bars to appear on the web browser. How can I resolve this without them? @import ...

implement a night mode with a single click

I attempted to implement a dark mode using jQuery, but it is not working as expected. I am seeking assistance. I would like to enable the dark mode when clicking on the #btntheme ID, but for some reason, it is not functioning correctly. My goal is to be ...

Assigning a class to a header upon loading the page from various sections at random

After scrolling, I used JavaScript to add a class to <header>. Here is the code snippet: $(window).scroll(function(){ var top = $(window).scrollTop(); if(top>=1){ $("header").addClass('bg-header'); } else ...

Experimenting with directive using jasmine

I've been working on this directive but I'm having trouble writing the jasmine test for it. Any suggestions? import { Directive, Output, EventEmitter, HostListener } from '@angular/core'; @Directive({ selector: '[ctrlKeys]&apos ...

Choose a pair of outcomes when utilizing Group By in a sqlite query

Let's dive into a complex scenario with an illustration: Consider a sqlite table with various fields (id, language, title, etc.) Each title can have multiple languages associated with it. id -- language -- title -- publication -- ...

Creating an interactive HTML form that updates in real-time based on user input can be achieved using vanilla JavaScript. This allows for a

I am working on a form that dynamically generates more form fields based on a user input value. <form> <input type="Number" name="delivery"> </form> For example, if the user enters '3', it should automat ...

Implementing Formik in React for automatic updates to a Material-UI TextField when blurred

Presently, I am developing a dynamic table where users can simultaneously modify multiple user details in bulk (Refer to the Image). The implementation involves utilizing Material-UI's <TextField/> component along with Formik for managing form s ...

Facing issue with local redis session not functioning as intended

I'm encountering an issue with my redis session not functioning properly when testing locally. EDIT: Additionally, I realized that it's failing to save a cookie when trying to set req.session[somekey] as undefined like so: req.session.user = u ...

Encountering an issue with jQuery: [ts] Expecting an identifier for $('.carousel').each(function(){})

In the process of developing an Angular project for a Multi-Item Carousel Advance which shows 1 item at a time, I have encountered a compilation error when utilizing JQuery. Despite having proper installation of JQuery, the error arises in the code snippet ...