Utilize CSS appropriately for various web browsers

Embarking on my web development journey.

Currently working with a CSS snippet that looks like this:

height: calc(100vh - 46px);

This code is effective across most browsers, but for Mozilla,

height: -moz-calc(100vh -46px );

It seems to work. However, I'm facing an issue where one overrides the other in different browsers. How can I ensure consistency across all browsers?

Any suggestions on resolving this issue would be greatly appreciated.

Answer №1

calc is well-supported in Mozilla as far as my knowledge goes. If you need more details on browser support for specific properties, you can always refer to Can I use.

In addition, it's a good practice to include prefixed rules along with regular ones like shown below:

.my-style {
  height: calc(100vh - 46px);
  height: -moz-calc(100vh - 46px);
}

Since browsers apply only one of these rules, there's no harm in including both.

To avoid the trouble of manually prefixing rules, tools like Browserify can automate this process for you. Another helpful tool is Autoprefixer, which identifies rules that require prefixes and guides you through the correct implementation.

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

Alert Div from Bootstrap fails to appear during the second ajax request if the first ajax request is canceled

I've implemented a dismissible alert in my HTML file that starts off hidden. Here's the code snippet: <div class="alert alert-dismissible" role="alert" id="msgdiv" style="margin-bottom:5px;display: none;"> <button type="button" clas ...

Modify the Google Maps icon based on the type of data within an array dynamically

Being new to the world of JavaScript, I've been given the task of converting an old jVector map to the Google Maps API. Surprisingly, I think I'm making good progress! I've successfully populated the map with the right markers in their assig ...

How can I transfer the data from a file to upload it in Angular 9 without manually typing it out?

In my Angular application, I have a functionality where users can upload two files for processing on the server. However, I am looking to add a feature that allows users to simply copy and paste the contents of the files into two textboxes instead of going ...

Struggling with displaying values from an array using getJSON

I've encountered an issue with displaying the results of a $.getJSON call. The code I have retrieves JSON data from a specific page. var loadItems = function() { if (hasNextPage === false) { return false } pageNum = pageNum + 1; var url = baseUr ...

I'm struggling to grasp the concept of how the backend and frontend interact with each other

The world of web development begins with HTML, CSS, and JavaScript for the frontend. HTML is essential as it allows browsers to render content in a readable format for humans. CSS comes into play to define the style and design of websites, while JavaScript ...

What is the best way to place <a> links next to each other in the header?

Looking to align the links horizontally in the header using CSS, can someone assist me with this? <body> <nav> <div class="wrapper"> <a href="index.php"><img src="spaceship.png" alt="blogs logo& ...

How to implement setState within a Promise function using useEffect in React functional components with hooks?

I am struggling to set the value of a hook within a Promise function inside a useEffect(), and then store the returned promise value in the fruit hook so that it can be accessed in the return function of MyComponent() This is what I have attempted so far: ...

What is the method to change lowercase and underscores to capitalize the letters and add spaces in ES6/React?

What is the best way to transform strings with underscores into spaces and convert them to proper case? CODE const string = sample_orders console.log(string.replace(/_/g, ' ')) Desired Result Sample Orders ...

Angular HTTP requests are failing to function properly, although they are successful when made through Postman

I am attempting to send an HTTP GET request using the specified URL: private materialsAPI='https://localhost:5001/api/material'; setPrice(id: any, price: any): Observable<any> { const url = `${this.materialsURL}/${id}/price/${price}`; ...

Fade in/out or apply opacity to a three.js object

I'm working on a graphical web project using three.js. I have many circles scattered like this. https://i.sstatic.net/y4FN8.png I'm curious if the opacity of objects can be reduced as the distance between the object and camera increases (fade ...

Is it possible to record a video and save it directly to the server?

When using the Apache Cordova Plugin cordova-plugin-media-capture to capture a video, you may wonder how to send this video to your server and store it. An official example is provided on how to start capturing a video: // capture callback var captureSuc ...

Issue: The element [undefined] is not recognized as a valid child of the <Routes> component. Only <Route> or <React.Fragment> components are allowed as children of the <Routes

I am facing an issue while trying to upgrade react-router-dom from v5 to v6. The error message I receive is as follows: Error: [undefined] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragm ...

unable to retrieve the value from the scope

I'm trying to implement the following code in HTML: <div ng-if="item.shareText"> <textarea></textarea> <div> <select ng-model="shareOptions"> <option value="PUBLIC" selected>public</option> ...

A platform for creating ER and flow diagrams specifically tailored for web applications, utilizing open source software

Our team is currently working on creating a web application that enables users to create diagrams, such as flow or ER diagrams. We are looking for ways to convert these diagrams into XML or other formats for representation. Are there any open-source soft ...

Retrieving specific data from nested arrays in Vue.js

I am currently working on Vue.js template development and facing an issue with filtering nested data in a faq section. When I try to add a search bar, the nested data array returns all data without proper filtering. Dom <v-container> <v ...

Utilize the size of the array as a variable

I have a question regarding the use of the length of an array as an integer value in JavaScript. Here is the code snippet: var counter = 0; var bannerLinks = document.getElementsByClassName("bannerlink"); var linkCount = bannerLinks.length; va ...

What steps can I take to prevent Internet Explorer from caching my webpage?

After implementing Spring MVC for Angular JS on the front end, I encountered an issue where logging in with different user credentials resulted in incorrect details being displayed. This problem only occurred in Internet Explorer, requiring me to manually ...

Tips for displaying res.locals information in the console for debugging purposes using ExpressJS and Nodejs

Currently, I am delving into the world of Node.js and ExpressJS as a novice in this realm. My primary requirement is to log the entire or partial content of res.locals in my console for debugging purposes. Here's what I've attempted: var foo_ro ...

Building a Category Directory in WordPress

Hello, I am currently working on creating a list of Categories for my website's Sidebar. However, the information I have found about displaying this category list does not allow me to style it as I want. Initially, I aim to showcase only the top 5 mos ...

What is the best way to pass a Python string to a JavaScript script?

I attempted to utilize the JSON module for this task, but encountered errors in both my JavaScript script and Firebug. For example, I have a line that looks like this: {"fruit":{"apple":100}} When trying to send this to a JavaScript script called jquery. ...