Why does the scrollbar appear even when the inner element is smaller in CSS transformation?

Please check out this link

.wrapper { 
  width: 200px; height: 200px; padding: 10px;
  border: 1px solid #888; overflow: auto;
}
.scale { 
  width: 400px; height: 300px;
  background-color: red; 
  transform: scale(0.4);
  transform-origin: 0 0; transition: all 0.5s ease-in-out;
}
.scale:hover { 
  transform: scale(4); 
}

When the inner div is visually smaller than its wrapper due to transformation, one would expect the scrollbar not to be visible.

However, there is a difference in behavior between Chrome and IE. In IE11, both x- & y-scrollbars are visible, while in Chrome only the y-scrollbar appears.

The hover effect over the inner div functions correctly.

My goal is to have no visible scrollbar in both IE and Chrome until hovering over the inner div. Is this achievable? Thank you.

Answer №1

One potential solution could be:

.resize { 
    width: 500px; height: 350px;
    background-color: blue; 
    transform: scale(0.5);
    transform-origin: top left; transition: all 1s ease-in-out;
    overflow: hidden;

}

.resize:hover { 
    transform: scale(2); 
    overflow: auto;
}

Answer №2

The primary reason for the vertical scroll bar appearing in your initial state is due to the inner DIV (.scale) having a greater height than the outer DIV (.wrapper):

.wrapper { 
  width: 200px; 
  height: 200px; /* <---- */
  padding: 10px;
  border: 1px solid #888; overflow: auto;
}
.scale { 
  width: 400px; 
  height: 300px;  /* <---- */
  background-color: red; 
  transform: scale(0.4);
  transform-origin: 0 0; transition: all 0.5s ease-in-out;
}

To prevent the initial scrollbar, adjust the size of the inner DIV to be equal to or smaller than the outer DIV.

It's worth noting that there may be complications when the user tries to grab and scroll the content since the scrollbars are not part of the inner DIV. This can lead to the :hover effect being disengaged and the scaling reverting back to its original, reduced size.

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

ReactJS does not trigger a re-render when changes are made to CSS

I'm curious about the reason why ReactJS does not automatically reapply CSS to child components even when componentDidUpdate() is called. I conducted a small demo where adding a new box doesn't change the color of existing boxes, even though the ...

Looping through an array of objects in VueJS can become a bit tricky when dealing with objects whose properties are dynamic. How can I efficiently

I am looking to create a matrix display from an array of objects, but the properties of the objects may change over time. Here is an example of the data: [ { location: "Japan", webhookStatus: "Up", authenticationStatus: &q ...

An effective method for targeting a specific button within a CSS file

I have multiple button tags in my code, but I need to style a specific one using CSS. How can I target this particular button and apply styles only to it while leaving the others unchanged? Do I need to assign the button to a variable and reference that va ...

Hide a div when multiple classes are filtered using jQuery

I have several divs with the class .item. When the user clicks on the Classfilter submit button, all .item elements that also have at least one class from the dateClasses array (for example ['28.09.2015', '29.09.2015']) should be hidden ...

checkbox-activated navigation bar

Struggling to implement a Nav-drawer that should open when a checkbox is selected, everything seems to be set up correctly but the issue arises when it comes to actually opening it. Here is the code snippet: <div class="leftside"> <input typ ...

Is there a way to implement an onclick event on a specific line of text that triggers a popup box only when the text is clicked, without the popup appearing automatically when

I received assistance from a fellow user to customize a popup that turned out great. However, I'm having trouble getting the onclick function to work properly so that the popup only appears when the phone number is clicked. Ideally, I want the phone n ...

What is causing the resistance in changing the color of my current navigation items?

I've encountered a small challenge with my header section. Despite multiple attempts, I'm struggling to change the color of the 'current' menu item. It seems that overriding Bootstrap's default color is proving to be more difficult ...

Ensuring the clickable area of the button aligns perfectly with the button itself and adjusting the arrow position to be

Check out the sandbox here: https://codesandbox.io/s/vigilant-currying-h7c3r?file=/styles.css If you are looking for the classes .line and .arrow, they are what you need. When you create an event, notice how the arrows appear too low, with the clickable a ...

Hide bootstrap card on smaller screens such as sm and md

Utilizing the Bootstrap 4.1 card component, I showcase categories within the right sidebar - check out a sample image of the card here: Card example image; When viewing on smaller screens, it's preferable to collapse this large card as shown in this ...

Various text sizes within a nested HTML list structure

I've developed a nested CSS class for an ordered list on my website, but I'm encountering a problem where each list item is appearing in different font sizes even though I have specified the font size. .number_list ol { font:normal 1.2em ...

I am experiencing an issue wherein after using jquery's hover() function, the CSS :hover state is not

Following the jquery hover function, the css hover feature ceases to work. In my html, there are multiple svg elements. A jquery script is applied where hovering over a button at the bottom triggers all svg elements to change color to yellow (#b8aa85). S ...

What is the best way to achieve consistent width in a material-ui card component?

How can I ensure that all these cards have the same width? https://i.stack.imgur.com/Ns3zw.png I'm experiencing an issue with achieving uniform card widths when using flexbox in material-ui. How can I resolve this? Is it necessary to utilize Grid fo ...

Creating a bezel design in CSS or Vue: A step-by-step guide

Embedding: https://i.sstatic.net/YfvQP.png Is there a CSS property that can be used to create the same angle as shown in the layout? I looked everywhere in the program but couldn't find this specific property. Tried searching here !: https://i.s ...

Manipulate and scale with jQuery

I am currently utilizing the jQueryUI library with its Draggable and Resizable functionalities to resize and drag a div element. However, I am encountering some unexpected behavior where the div jumps outside of its container upon resizing. How can I resol ...

How to attach input to function invocation in Angular 2

Can we connect the @Input() property of a child component to a parent component's function call like this: <navigation [hasNextCategory]="hasNextCategory()" [hasPreviousCategory]="hasPreviousCategory()" (nextClicked)="next ...

Tips for creating a dynamic variable for an object key in jQuery to streamline your code

Utilizing the TweenMax library, I am adding styles to a div while scrolling. However, I am facing a challenge where I need different styles based on varying page resolutions. To address this issue, I implemented an if condition. Is there a way I can use a ...

Submenu Positioning Problem Identified in Firefox Display

I am currently working on a menu design for a website and encountered an unusual issue while testing it in Firefox. In the provided fiddle link, you can view the menu layout where hovering over the information button should display a submenu directly below ...

Conceal or eliminate redundant choices in dropdown menu

I am currently working with the WebForms framework and I have encountered an issue with my dropdownlist control in one of my Forms. The Select option is sometimes being added twice, causing duplication in my form. I am looking for a way to either remove th ...

The fields in the row of the Rails form_tag are overly spacious

My login form in Rails 4 with Bootstrap 3 is giving me trouble. It doesn't format well on any device, especially smaller screens where it becomes unusable. I suspect the huge right margin of the rows is to blame, but I can't figure out the root c ...