Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS scale from left top

Tags:

html

css

scale

I am trying to scale my entire page from the top left. This is what my original page looks like:

enter image description here

However when I try to scale my page, this happens:

enter image description here

This is my CSS:

html {     zoom: 1.4; /* Old IE only */     -moz-transform: scale(1.4);     -webkit-transform: scale(1.4);     transform: scale(1.4);     transform-origin: top left; } 

What am I doing wrong? It cuts off part of my page.

like image 446
2339870 Avatar asked May 20 '14 13:05

2339870


People also ask

What is Transformorigin?

CSS Demo: transform-origin The transform origin is the point around which a transformation is applied. For example, the transform origin of the rotate() function is the center of rotation.

How do you change the scale in CSS?

scale() The scale() CSS function defines a transformation that resizes an element on the 2D plane. Because the amount of scaling is defined by a vector, it can resize the horizontal and vertical dimensions at different scales. Its result is a <transform-function> data type.

How do you scale a center in CSS?

Just replace width: 400px; with transform: scale(2,2) on :hover . transform-origin: center; ? @oCcSking it is the default value Default value: 50% 50% 0 as in Specifications developer.mozilla.org/en-US/docs/Web/CSS/transform-origin Initial value 50% 50% 0 .

What is the use of scale in CSS?

A CSS scale () function is defined as a CSS Transformation property which allows resizing an element in the Two-dimensional Plane. It is used to increase or decrease the size of an element. When a scale transformation is applied it is necessary to instruct the browser about the numbers to resize.

What is the difference between left and relative position in CSS?

If position: absolute; or position: fixed; - the left property sets the left edge of an element to a unit to the left of the left edge of its nearest positioned ancestor. If position: relative; - the left property sets the left edge of an element to a unit to the left/right of its normal position.

What is position in CSS layout?

CSS Layout - The position Property. ❮ Previous Next ❯. The position property specifies the type of positioning method used for an element (static, relative, fixed, absolute or sticky). The position property specifies the type of positioning method used for an element.

What does the left property do in CSS?

Definition and Usage. The left property affects the horizontal position of a positioned element. This property has no effect on non-positioned elements.


2 Answers

I was able to "solve" my problem.

This is what I tried:

  • In the CSS shown in the question, I changed html to body:

    body {     zoom: 1.4; /* Old IE only */     -moz-transform: scale(1.4);     -webkit-transform: scale(1.4);     transform: scale(1.4);     transform-origin: top center;     margin-top: 5px; } 
  • I changed transform-origin: top left to transform-origin: top center.

  • I also changed the CSS of my container div so that it is centered.

This fixed the problem partly as it centered to page nicely.

However, part of the top page still isn't displayed correctly. To fix this I added a margin-top to my body.

like image 74
2339870 Avatar answered Sep 27 '22 19:09

2339870


I know this question is 3 years old but I just stumbled on it. The reason your transform is not positioned correctly is because your transform-origin parameters are backwards and thus are ignored. It's "transform-origin: x-axis y-axis" so you should have "transform-origin: left top", not "transform-origin: top left".

like image 20
kbriggs Avatar answered Sep 27 '22 20:09

kbriggs