What are the steps for enlarging the display containing components with the 'position: absolute' style?

How can I magnify the screen with the following code?

.drawing-board {
  width: 25%;
  height: 25%;
  background-color: black;
  position: relative;
  /* transform: scale(2, 2); */
}

.drawing-board .box-1 {
  width: 20px;
  height: 20px;
  background-color: yellow;
  position: absolute;
  left: 90px;
  top: 90px;
  transform: scale(2, 2);
}

.drawing-board .box-2 {
  width: 20px;
  height: 20px;
  background-color: lime;
  position: absolute;
  left: 30px;
  top: 30px;
  transform: scale(2, 2);
}
<div class="drawing-board">
  <div class="box-1"></div>
  <div class="box-2"></div>
</div>

Initially, I assumed that using transform: scale() on all elements would enlarge them

Can you provide any examples demonstrating this concept?

Answer №1

Applying the transform to the parent element results in scaling everything, including the distance between the child elements. If you are facing issues with parts disappearing or overflowing to the left, you can utilize transform-origin to specify the origin point for the transformation:

.drawing-board {
  width: 25%;
  height: 25%;
  background-color: black;
  position: relative;
  transform: scale(2, 2);
  transform-origin: left top;
}

.drawing-board .box-1 {
  width: 20px;
  height: 20px;
  background-color: yellow;
  position: absolute;
  left: 90px;
  top: 90px;
}

.drawing-board .box-2 {
  width: 20px;
  height: 20px;
  background-color: lime;
  position: absolute;
  left: 30px;
  top: 30px;
}
<div class="drawing-board">
  <div class="box-1"></div>
  <div class="box-2"></div>
</div>

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

The OTP submission in Phone Email's phone authentication using Node JS did not result in the reception of the token

I have implemented the “Login with Phone” Button from Phone Email on my Node JS website. The button opens a popup to enter the mobile number and then displays an OTP window after submission. Although I receive the OTP SMS and enter it successfully, I a ...

Display a specific division depending on the outcome of an Ajax request within a PHP form

My PHP form has a layout similar to this: <form> <div id="inid"> National ID: <input type="text" id="individual_nid" oninput="getIndividualName(this.value)" /> </div> <hr /> name: <div id="individua ...

Exploring CSS shaders in a browser?

Which browser out there fully supports CSS shaders? ...

Having trouble getting my node.js and socket.io code to function properly

This is my code for basic broadcasting functionality on the server side: Server Side var socket = require( 'socket.io' ); var express = require( 'express' ); var http = require( 'http' ); var app = express(); var server = h ...

What methods can I use to prevent a user from accidentally double clicking a link within an email?

After users request a password reset, they are sent an email containing a link to create a password reset code. This link remains valid for 24 hours and can be utilized multiple times within that time frame to generate new codes in case the initial one is ...

Activate the submit button using jQuery

I have tested the code snippet that I shared on fiddle. I am looking to activate the save button by hitting the enter key, which will submit the form using ajax. The activation should occur when there is text content greater than 0 in the span. $(docum ...

Struggling to set a background image for multiple div elements

Hey everyone! I'm working on a small school project website and I've run into an issue with the background on multiple div elements. Here's my HTML code snippet: <div class="bloc-1-text"> <h3> </h3&g ...

Angular services Eclipse Mars JavaScript validation

When using Eclipse validator, it seems that the keywords "finally" and "catch" are not allowed: $http.get(url) .success(function (data) { // Handle data }) .error(function (data, status) { // Handle HTTP error }) .finally(function () { // Ex ...

The jQuery menu is malfunctioning in Internet Explorer due to the Document Mode being set to Quirks

I am encountering an issue where the below code is not functioning properly in Internet Explorer's document mode quirks. Each time I hover over the submenu, its length doubles unexpectedly. Can someone please provide assistance with this matter? < ...

Preventing event bubbling/propagation in custom events: a step-by-step guide

Incorporating a module-project from Github into my Angular project, I am able to resize the DOM elements that are displayed on top of a div functioning as a drawing board. To configure my initial rectangles, I am utilizing a combination of mouseDown - mou ...

What is the best way to transform a Ruby hash into a JavaScript object while maintaining unquoted values?

Is there a way to display a Ruby hash as a JS object without quotes for certain values in the hash, essentially as JS code? For instance, consider the following Ruby code: { foo: proc { 'someJavascriptFn()' } }.to_json How can I have the JS out ...

Directive not working on Mozilla Firefox

Currently, I have a directive set up to display an image as a background image. This works perfectly fine in Chrome and Safari, but for some reason, it doesn't seem to be functioning properly in Firefox as the background images are not showing up. Aft ...

Ways to align one child to the end without affecting any other elements

I'm attempting to position only div3 at the flex-end of .app. If I use this code: .app { display: flex; flex-direction: column; height: 100vh; justify-content: flex-end; } Div3 goes where I want it, but everything else also moves dow ...

What causes the default styling of a browser user agent to be altered when a background image is added to an input button?

Take a look at this example: http://jsfiddle.net/eJSGn/ input{ padding-left: 20px; } input:last-of-type{ background: url(http://skiorboard.com/wp-content/uploads/2014/03/search.png) no-repeat; background-size:15px 15px; } <in ...

Persistent NW.js Local Storage Cache Remains Present even After Deleting Application

I have been encountering an issue in my NW.js app where I store data in the Local Storage. Even after deleting the app and cleaning up cache information, the Local Storage data seems to persist. When I reinstall the app, the stored data reappears as if it ...

Get information that has been uploaded using ajax

I need help with my code for sending data via ajax to an update.php page. $(document).ready(function() { $("#modify").click(function() { var a = $("#a").val(); var b = $("#b").val(); var c = $("#c").val(); $.ajax({ type: "POST", ...

How can you define rules for font fallbacks that are specific to each font?

There are times when web fonts fail to load, especially if hosted on platforms like Google Fonts. In such cases, fallback fonts may require special attention as they can vary significantly from the originally specified fonts. For example: font-family:&ap ...

JSRender: A guide on accessing variables from outside the block

I am currently using jsrender to display the details of my JSON object. One thing I'm trying to figure out is how to access an external variable from within the list. Any help would be greatly appreciated. <script id="itemTemplate" type="text/x ...

Setting up multiple classes in my unique situation

Setting up an ng-class in my app My current setup looks like this: $scope.myClass = 'class-A'; Performing a task here... $scope.myClass ='class-B'; Performing another task here $scope.myClass ='class-C'; html <div n ...

Postman Guide: Mastering the Evaluation of JSON Arrays

One of the features in Postman allows users to save a specific field from the response body as a variable and then utilize that variable in a subsequent call. For instance, after my initial call to the web service, the response body contains: [ { "id" ...