Unable to calculate height properly when using the formula height: 70% + 0px

My attempt to set the height of a div element to 70% using CSS3's calc() function has been unsuccessful. While specifying viewport height (70vh) works, I specifically need the height to be 70%.

.scroll-inner-container {
  height: -moz-calc(70vh + 0px);
  height: -webkit-calc(70vh + 0px);
  height: calc(70vh + 0px);
  overflow-y: scroll;
}

.scroll-outer-container {
  position: relative;
  height: 100%;
  background-color: #ededed;
  padding: 0px 20px;
}
<div class="pf_content tab-pane">
  <div class="scroll-outer-container">
    <div class="scroll-middle-container>
      <div class="scroll-inner-container">
        <div class="paragraph-space content">
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores consequatur, voluptas aspernatur ducimus sapiente rem quis cumque expedita quia nisi! Labore vel ut veritatis, magnam itaque quibusdam sed nemo, doloribus accusamus voluptatem quae. Delectus
            minima excepturi, voluptatem consequatur voluptatum, in assumenda, harum aperiam fugit doloremque, cupiditate natus animi sed odit! Libero delectus maxime, corrupti quos nisi facilis labore porro consectetur in, quaerat at repellendus perspiciatis,
            dicta placeat. Ullam doloribus reiciendis laborum, similique, inventore culpa. Asperiores tempora debitis voluptatum facere maiores iste fugiat quisquam necessitatibus. Esse impedit similique, iusto. Omnis voluptatibus quo animi a repellendus
            vero modi? Odit tenetur, tempore laboriosam reprehenderit vitae dolorem inventore placeat illo iure dicta iste minima asperiores eos dignissimos, quis et officia sapiente, distinctio animi deserunt voluptatum. Unde quo dolores est id numquam
            perspiciatis consequuntur beatae, optio quia ut explicabo officia nihil itaque quidem adipisci maiores, vitae accusamus. Commodi deserunt id, natus consequuntur tempore. Voluptates adipisci, perferendis ex quae cumque repellendus, cupiditate
            a iste maiores, pariatur fugiat officia voluptatum. Fuga excepturi, at, ut doloribus ipsum quis itaque voluptate repellendus sint vel aut in alias. Repellat...

Answer №1

https://i.sstatic.net/CMThH.png

I tried copying your code and found that calc(70% + 0px) is functioning correctly. It seems like you may have forgotten to add a space after and before the "+" sign in your code. For example, if it looks like this calc(70%+0px), it will not work

To make it work, simply write it exactly like this: height : calc(70% + 0px); and it should work fine

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

Safely render user-generated HTML content within a React application to prevent cross-site scripting vulnerabilities

A unique situation has arisen in our React app where a user inputs a string that is displayed to other users. The challenge lies in searching for specific characters within the string and replacing them with HTML elements. For example, transforming the wor ...

Using jQuery to filter or duplicate options in a select box - a step-by-step guide!

I am struggling with filtering options in two select boxes. One contains projects and the other contains people: <select id="project"> <option data-person_ids="[75,76,77]">None</option> <option data-person_ids="[77]">Project A& ...

Place a user input field within a div element having the specified class

I am trying to insert an HTML input element into the following div: <div class="sss" style="padding-top:2px"> <center> <input value="test1" name="name1" type="submit" > <input value="test2" name="name2" type="submit"> </c ...

WordPress footer widgets appearing misaligned

I have made a child theme for Twenty Thirteen and am in the process of making some updates to it. My development site is essentially a replica of the live site. The only modification I made in the footer section was to change the widget title styles, but I ...

"Enhance Your Asp.net Search Functionality with this Exciting jQuery Plugin

Currently, I have a website built on Asp.net Web Forms and I am looking to enhance the search experience by using a plugin. I specifically want to utilize a cached dataset for faster search results. Most jQuery chosen select plugins are not compatible with ...

Ways to turn off the dragging animation for cdkDrag?

I am facing an issue with cdkDrag where a small preview of the item being dragged shows up. I want to disable this feature and remove any CSS classes related to the dragging state. Can anyone guide me on how to achieve this? https://i.sstatic.net/nYU07.pn ...

Adjust the size of images using jQuery to perfectly fit the container dimensions

I am currently working on a script to automatically resize images that are too large for the container: $('img').each(function(i){ var parent_width = parseInt($(this).parent().width()), image_width = parseInt($(this).width()); ...

How can I link an HTML anchor to a calendar?

Is there a way to create a universal link that generates a calendar event using HTML? For example, we can create an email link with <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff9e9b9b8d9a8c8cbf9a879e928f9 ...

Experiencing a problem when attempting to activate the html5 mode feature in AngularJS to eliminate the #

I've been scouring through various sources like stackoverflow and the web, but I haven't found a clear answer to my question. Can someone please help me out? Here's what I'm struggling with: In my AngularJS application, I enabled &apos ...

Determine the currently active view on a mobile device

I am trying to determine whether the user is viewing the website vertically or horizontally on their mobile device or iPad in order to adjust the image scale accordingly. For example: If the user is viewing the page horizontally, I want the image style t ...

When I engage with the input field, it ceases to be in focus

Here is the code I've been working on: https://github.com/Michael-Liendo/url-shortener/blob/main/src/pages/index.js If you want to see the issue for yourself, check it out at: ...

Adding a scroll bar to a fixed container: tips and tricks

I am looking to implement a scrollbar in a fixed container for the cart products. The goal is to enable easy navigation through a large number of products added to the cart by scrolling within the container. Below is the HTML code snippet representing the ...

Issue with Translate3d functionality in fullpage.js not functioning as expected

Currently, I am in the process of constructing a website using fullpage.js with WordPress. Everything is functioning well except for one issue - when attempting to disable the plugin by using destroy() or changing setAutoScrolling to false, the translate3d ...

Field for text input enclosed within the <select> tag

I have a project where I am implementing a dropdown using AngularJS. Here is the code snippet: <div class="col-md-9"> <input type="text" placeholder="Enter Module" list="names" ng-model="data.Name" /> <select id="names" class ...

utilizing jquery for multidimensional json arrays

Feeling frustrated as I try to grasp the intricacies of JSON data structure. An undefined multidimensional array is coming from a web API, and its layout looks like this: { "totalCount": 30, "entries": [{"title": "item1","description": "your amazing item ...

Clicking randomly on the page to conduct test trials

Currently, I am seeking a way to ensure that my web page is flawless, specifically in terms of broken paths. Given that my website will utilize a touch screen interface, it is crucial to test the entire page thoroughly. While I have limited experience in a ...

Execute an ajax request using a PHP script

I'm currently in the process of testing an ajax post request that involves sending my formData object through a PHP script (despite my lack of knowledge in PHP, I was provided with the necessary script). My setup includes a local PHP file named index ...

When I toggle the div to close on mobile, I want it to show on desktop

My attempt at creating a toggle button to hide and show content was not successful. I struggle with coding in Javascript/Jquery. In the desktop view, the description displays perfectly (see image here), but in mobile view, there is a button to toggle hidi ...

"VS Code's word wrap feature is beneficial for wrapping long lines of text and code, preventing them from breaking and ensuring they are

text not aligning properly and causing unnecessary line breaks insert image here I attempted to toggle the word wrap feature, installed the Rewrap plugin, and played around with vscode settings ...

Issue with integrating SQL and PHP/HTML using a web form

I've encountered some challenges while attempting to create a social network database, specifically with inserting values into the user_ table. The database setup is in place, but there are no updates happening (no output code when redirecting to PHP ...