Does CSS Perspective make lower values appear bigger?

When looking at a cube from different perspectives, as shown in this example: http://codepen.io/HugoGiraudel/pen/GLbca

The cube on the right has a perspective of -webkit-perspective: 250px;, while the one on the left has -webkit-perspective: 1000px;

According to Mozilla: "The perspective CSS property defines the distance between the z=0 plane and the user, creating a sense of depth. Elements with z>0 appear larger, while elements with z<0 appear smaller. The value set for this property determines the strength of the effect."

In this scenario, the right cube should be closer to the user by 750px, so why isn't it significantly larger than the left cube? Furthermore, if you adjust the perspective using dev tools to an extensive number like 10000px, the size of the cube remains the same. Shouldn't it become extremely small?

Here is the code snippet provided by http://codepen.io/HugoGiraudel/

<div class="wrapper w1">
  <h1><code>perspective: 1000px</code></h1>
  <div class="cube">
    <div class="side front">1</div>
    <div class="side back">6</div>
    <div class="side right">4</div>
    <div class="side left">3</div>
    <div class="side top">5</div>
    <div class="side bottom">2</div>
  </div>
</div>
<div class="wrapper w2">
  <h1><code>perspective: 250px</code></h1>
  <div class="cube">
    <div class="side front">1</div>
    <div class="side back">6</div>
    <div class="side right">4</div>
    <div class="side left">3</div>
    <div class="side top">5</div>
    <div class="side bottom">2</div>
  </div>
</div>

And here is the accompanying CSS:

.wrapper {
  width: 50%;
  float: left;
}

.w1 {
  perspective: 1000px;
}

.w2 {
  perspective: 250px;
}

.wrapper h1 {
  text-align: center;
}

.cube {
  font-size: 4em;
  width: 2em;
  margin: 1.5em auto;
  transform-style: preserve-3d;
  transform: rotateX(-40deg) rotateY(32deg);
}

.side {
  position: absolute;
  width: 2em;
  height: 2em;

  background: rgba(tomato, .6);
  border: 1px solid rgba(0,0,0,.5);

  color: white; 
  text-align: center;
  line-height: 2em;
}

.front  { transform: translateZ(1em); }
.top    { transform: rotateX( 90deg) translateZ(1em); }
.right  { transform: rotateY( 90deg) translateZ(1em); }
.left   { transform: rotateY(-90deg) translateZ(1em); }
.bottom { transform: rotateX(-90deg) translateZ(1em); }
.back   { transform: rotateY(-180deg) translateZ(1em); }

Answer №1

It's important to remember that what truly shifts is the angle of view, not just the size.

Asking the question:

In this scenario, why isn't the cube on the right considerably larger if it should be 750px closer to the viewer?

The key concept to grasp here is that the 750px represents a change in perspective, not necessarily in size.

The crucial element lies within the specifications:

For every 3D object with z>0, it appears bigger; for those with z<0, it appears smaller

Your cube is situated at the center point (even though there may not be anything tangible there), so each face experiences an equal movement but in opposite directions. This results in the size remaining constant at the cube's center.

If you visualize the cube being sliced by the z plane, it doesn't alter its dimensions along that plane.

While the front face enlarges and the backface diminishes slightly, this shift is most noticeable at the vertices closest or farthest from the viewpoint.

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

Place a gap between each image

I currently have three posts on my front page, each spanning the full width of the page. I want to add a 30px padding to the left of these posts, but I'm facing an issue where there is also a 30px padding at the beginning of each row. My goal is to on ...

The clientHeight property is yielding a result of zero

I'm using JavaScript to create DOM elements dynamically. In order to animate a slide down effect, I need to retrieve the height of a specific div element. However, both clientHeight and offsetHeight are returning 0. I have confirmed that the div eleme ...

What is the process for dividing a form into two separate columns?

I am working on a form that sends input to a PHP script. I want to reorganize the form so that the second section (Person 2) appears in a column to the right of the first section (Person 1), instead of below it. <link rel="stylesheet" href="test.css" ...

Highlight the text element that has been clicked

I'm looking to create a list of text elements that can be underlined when clicked individually. Adding the text decoration to the tabText applies it to all items, but I need a way to remove the underline from the previously clicked tab when clicking o ...

Utilize HTML/CSS for text that changes automatically

Is it possible to dynamically change text using HTML and CSS based on the page being viewed? For example, when on the home page, the text would automatically display "Home Page" without needing manual changes on each page. I want this process to be seamles ...

Is it possible to integrate this ReactJs project into my Electron-based web application?

Currently, I am a novice in JavaScript and am working on developing a web application for my school project using Electron.js. At the moment, my project consists of JS, CSS, and HTML code only. You can view the homepage of my program on Codepen. [Codepen] ...

Ensuring that two columns in Bootstrap 3 have equal heights while including padding

I would like to achieve this design without using JavaScript. Here is a screenshot for reference: This is what I have created so far using Bootstrap 3. The CSS is inline due to the use of less, which makes it easier :) HTML <section class="container ...

Utilizing CSS and JavaScript for Image Masking

Is it possible to create a div that takes on the shape shown in this image and then fill it with an image? Alternatively, is there a way to transform an image into that particular shape using CSS or Javascript? Additionally, is it possible to arrange m ...

How can I stop and hover over time in AngularJs Interval?

Within my UI, I have a time element that is continuously updated using AngularJS Interval. Even the milliseconds are constantly running. Is it possible to implement a feature where the time pauses when hovering over it? Any assistance would be greatly appr ...

Troubleshooting a problem with the Bootstrap dropdown menu

Can anyone assist with an issue regarding Bootstrap 4.4.1? I am facing a problem where two consecutive dropdown links+menus are not displaying correctly. The second dropdown menu is showing the content of the previous link instead of its own, even though t ...

Utilize CSS to selectively apply the mix-blend-mode property to targeted elements

In my project, I am aiming to utilize the mix-blend-mode property to give certain SVG paths the appearance of an erasing path by blending them with a background image on the stroke. However, I have encountered a challenge where the mix-blend property affec ...

Leveraging the jQuery method .stop() to halt solely the .fadeTo() animation

My webpage features two jQuery effects applied to a <div>. Using the animate() function, I move it left and right, while utilizing fadeTo() to fade it out when the mouse is not hovering over the <div>. To prevent multiple fading effects caused ...

Is using display:table an effective approach for achieving equal height columns?

I am currently working on a responsive design project and I need two columns of equal height. I do not want to rely on JavaScript for this, and I prefer having some whitespace between the columns to enhance readability. I have tried two different layouts; ...

What is the best way to align a square div in the center between two columns using Bootstrap?

I am working on a layout that consists of two columns in a row with col-6, and a jumbotron. Here is the code snippet I have: <div class="jumbotron text-left" style="background-image: url(https://mdbootstrap.com/img/Photos/Others/gradient1.jpg); backgro ...

Utilize the identical mathematical equation across various jQuery values

I have a JavaScript code that calculates the size of circles on the screen based on multiple variables. Currently, I am repeating the same equation for each circle by numbering all the variables accordingly. Is there a way to simplify this process and run ...

Struggling with generating forms using AJAX, Javascript, and HTML depending on the selection made from a drop-down menu

I am in need of a simple web form for work submissions within my organization. These submissions will fit into 4 Categories, each requiring unique information. Currently, I have a basic form set up with fields such as Requested Name, Requested Date, Acquis ...

What causes the width of a card to vary between Windows and a Macbook Pro?

Here is the code I have: <div id="app"> <v-app id="inspire"> <v-content> <v-container> <v-card max-width="1000" class="mx-auto" > <v-form v-model="valid"> ...

This is an alignment of the background image ('relative') to the right side

I am facing an issue with the header section of my website. The background-image is styled using the following CSS: .header { position: relative; min-height: 436px; background: url("../img/holland-canal.jpg") no-repeat; background-size: co ...

`Jump-start Your Development with jQuery Lightbox Centering`

Recently, I implemented a lightbox effect for images on my website. However, I encountered an issue where the lightbox was not centering properly in the window upon initial click. Instead, the lightbox would appear at the bottom of the page on the first cl ...

The outerHeight of Elements measured in pixels

Is there a way to increase the outerHeight() function by adding extra pixels? Let's say we have a variable storing the outerHeight of .pg-sect: var $section = $('.pg-sect').outerHeight(); Now, if I want to add an additional 70px to the he ...