The issue with Google Font not loading in Safari and Firefox in a Vue.js app with CSS styling

I'm currently in the process of building a Vue portfolio and I've encountered an issue with setting the global font style to Montserrat. Oddly enough, while Chrome is able to reflect the CSS changes correctly, Safari and Firefox are throwing errors indicating that they are unable to access the Google Fonts URL.

I have experimented with various methods including using @import syntax, font-face syntax, and href links directly in the HTML. Additionally, I attempted to download the fonts and host them within my Vue application, but unfortunately, I haven't been successful in getting it to work as I am still relatively new to Vue development.

Here's what I currently have:

<link href="https://fonts.googleapis.com/css?family=Montserrat:400&display=swap" rel="stylesheet">

While this code does enable Chrome to display the correct font, copying and pasting the URL into either Firefox or Safari results in both browsers being unable to load the page. Upon inspecting the page, both browsers indicate that they are unable to fetch the resource from fonts.google.

In the style section of App.vue:

#app {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  font-family:'Montserrat', Arial, sans-serif;
  font-style: normal;
  font-weight: normal;
}

I also tried another approach by defining the font face in the HTML:

@font-face {
  font-family: 'Montserrat';
  src: url('/assets/fonts/Montserrat-Regular.woff2') format('woff2'),
   url('/assets/fonts/Montserrat-Regular.woff') format('woff'),
   url('/assets/fonts/Montserrat-Regular.ttf')  format('truetype');
}

Furthermore, I tested a basic import statement:

@import url('https://fonts.googleapis.com/css?family=Montserrat:400&display=swap');

Unfortunately, none of these solutions seem to be effective. You can simply paste

https://fonts.googleapis.com/css?family=Montserrat:400&display=swap 

into Chrome and witness the font selectors, whereas Firefox and Safari fail to even load the page.

My expectation was to have the Montserrat font displayed consistently across Safari, Firefox, and Chrome, yet currently it only renders correctly in Chrome.

Answer №1

Resolved: Issues with the host file are causing Google fonts to not display in browsers other than Chrome, or to not transmit fonts to different devices when serving as a local host.

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

Troubles with Vue and localStorage for storing a theme's data

I've been struggling with this issue for a while now while working on a Vue site. I have not been able to find a solution for my specific bug in other discussions. The concept should be straightforward - I want to have a switch that toggles a value b ...

Deletion of a custom function in JavaScript

I have written some basic code to generate and remove an image using functions. Specifically, I need help with removing the image created by the function Generate() when a button linked to the function Reset1() is clicked. Here's the code snippet for ...

What is the best way to align the right column section below the left column section on a reduced screen size in a responsive design?

When the screen size is small, I want the "left-side" of my project to be displayed above the right side. The problem I'm facing is that as the screen shrinks, the left side starts getting hidden by the right side until it suddenly jumps to the right ...

Looking for assistance with CSS coding for an XML table

Struggling with styling an XML file into a table using CSS. Despite multiple attempts, I just can't seem to achieve the desired look. Provided below is my XML code. Seeking assistance from anyone who can offer a solution to this perplexing issue. &l ...

Is there a way to adjust the speed of the transitions between animations?

I've been experimenting with ways to increase the time between animations in my cycle. Adjusting the duration of the keyframes animation hasn't yielded the desired effect. span { animation: rotateWordsFirst 15s linear infinite 0s; ...

Discover the power of Vuetify's message translation in combination with Nuxt i18n

I am looking to implement translated error messages for Vuetify validation failures Template section <v-text-field v-model="message.name" outlined :label="$t('page.contact.form.name')" :rules=nameValidation ...

Can an onSnapshot event be set up for an array in order to track changes?

In my system, each user is associated with multiple groups. Each user's group membership is stored as an array within their user document. Additionally, there is a tasks collection where each task contains an array of authorizedGroups that correspond ...

JavaScript - exploring techniques to alter the relationship between parents and children

I'm facing an issue with transforming the parent-child relationship in my data structure. Currently, it looks like this: { "id": 7, "name": "Folder 1", "parent_folder": null, "folders": ...

The HTML and body elements do not possess a width of 100% within the document

When viewing my portfolio site on smaller screens such as 425px and below, there is a white gap on the right side. This issue arises because the HTML and body elements do not inherit full width by default. Do you know why this happens and how I can resol ...

When using Vue 3, Vite, and Vuex together, an error message stating 'Uncaught ReferenceError: Cannot access 'store' before initialization' may appear in the console if running the command `npm run dev`

I am puzzled by this error message. Everything seems like it should be working fine, right? This is the content of my main.js file: import "tailwindcss/tailwind.css" import { createApp } from 'vue' import App from './App.vue&apo ...

What is the proper method for utilizing colspan within the footerData of a jqGrid?

Are you looking to customize the footer of your jqgrid as shown in the example below? I am trying to set up a custom footer for my jqgrid similar to the one displayed above. I have already enabled the footerrow:true option and used $self.jqGrid("footerDat ...

What are some ways to design a side-by-side arrangement of an image and a label?

I've been attempting to achieve the design shown below, but have been unsuccessful so far: https://i.sstatic.net/N9jGH.png .exploreItem { background-color: #353258; /* rgba(31, 31, 31, 1) */ border: 1px solid #4152F1; color: white; /* pa ...

Only execute jQuery if the last visited page was the homepage

On the homepage, the CSS that is initially loaded on the JSFiddle is present. My goal is to have the inner pages transition to their new CSS class only when visited after the homepage. <div class="container"> <div> Thank you for your ass ...

Avoid replacing CSS properties, instead use jQuery to supplement them

Can anyone help me figure out how to use the jquery .css() function without overwriting existing values, but instead adding additional values to css properties? For example, I have an element that currently has the css transform:translate(-50%, -50%). I w ...

Centered image

I am working on a website and struggling to center the image on all screen sizes. I attempted the following code:- <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" lang ...

"I can't seem to get this alignment right. What's going on

Is there a way to adjust the spacing more effectively? When the screen is resized, there is a large gap as highlighted in the red circle. My goal is to have it align correctly with the other divs instead of its current behavior. Thank you! https://i.sstat ...

Display a div every 3 seconds with the help of jQuery

I am seeking a solution to display the second div (box2) every 3 seconds. Can anyone help me achieve this using jQuery? <div id="box1" style="background-color:#0000FF"> <h3>This is a heading in a div element</h3> <p>This ...

What is causing the issue of the div not being removed from the label renderer in three.js

Hello, I've been trying to solve this issue for the third time now without much success. The problem I'm facing is related to creating a div at runtime and then attempting to remove it after clicking on it. Although I've tried removing the d ...

Conceal the footer when the website is scrolling, reveal it when the website is not scrolling

Before I pose my question, I need to establish two constraints: Must be compatible with IE 7+ Only able to modify the CSS, cannot adjust the HTML/JS So, I have two divs: <div id="content"></div> <div id="footer"></div> "#conten ...

What are the best ways to engage with the Mixcloud Widget?

I have a component with a mixcloud embed code, which looks like this: <template> <div> <iframe id="widget" width="100%" height="60" :src="iframe.src" frameborder="0" v-show="iframe.loaded"></iframe> </div> </templ ...