The issue of scrolling while utilizing CSS scale

I'm currently facing an issue with CSS and I must admit that I am still in the learning process.

My goal is to have a header that remains at the top of the page, while the content area should be scrollable.

Below are the two CSS classes I've been working with:

.body,
        .div {
            margin: 0;
            padding: 0;
        }

        .body {
            overflow: hidden;
            width: 100%;
            height: 100%;
        }

        #header {
            overflow: auto;
            position: absolute;
            width: 100%;
            height: 200px;
            background-color: #DEE7F2;
            border-width: 2px;
            border-bottom-width: 2px;
            border-bottom-color: black;
            border-bottom-style: solid;
        }

        #main {
            overflow: auto;
            position: absolute;                
            top: 200px;
            width: 100%;
            bottom: 0;                
        }

<body>
    <div id="header">
        some stuff here
    </div>
    <div id="main">
        a lot of stuff here
    </div>
<body>

Everything seems to work well with these settings. However, I recently added a dropdown menu to choose the scale of the "content" area because the content will be extensive.

Here is the additional CSS class I implemented to make the main div scale to 10%:

.scale10 {
            -ms-transform: scale(0.1);
            -moz-transform: scale(0.1);
            -o-transform: scale(0.1);
            -webkit-transform: scale(0.1);
            transform: scale(0.1);
            -ms-transform-origin: 0 0;
            -moz-transform-origin: 0 0;
            -o-transform-origin: 0 0;
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
        }

When viewed at 100% scale (without the additional class), here’s how the page looks:

It's evident that the page has been scaled but is not utilizing the entire width of the screen. The scrollbars also do not span the entire width. Although I included "width: 100%" in the main class, removing it causes the scrollbars to disappear...

What I’m aiming for is to scale the main-div while keeping the width at 100% so that the image fills the entire screen. Additionally, I need the scrollbars due to the content exceeding the screen size, even with a 10% scale applied.

Is there a CSS wizard who can assist me with this challenge?

Answer №1

If you want to achieve this effect, follow these steps:

Check out the JSFIDDLE demo here.

To create the desired effect, enclose your content within another container and place that container in your main area. Then, instead of scaling the main area, focus on scaling just the content itself.

body,
html {
  height: 100%;
}

#main {
  width: 100%;
  height: 100%;
  background-color: black;
  overflow: auto;
}

.content {
  width: 500px;
  height: 400px;
  margin: 0 auto;
  background-color: white;
  transition: all 1s ease;
  -webkit-transition: all 1s ease;
}

.content:hover {
  width: 120%;
}
<div id="main">
    <div class="content"></div>
</div>

This example includes a hover state for demonstration purposes.

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

Firebase - accessing the most recent entry

I have a node server up and running where I need to monitor updates in a collection and retrieve the newly added data. My approach was to utilize db.collection("posts").onSnapshot to listen for updates and fetch the latest entry by ordering it ba ...

Untriggered express GET routes with HTML pages

My application is quite simple, so I didn't feel the need for a comprehensive front-end template like Angular, and I was hesitant to use Jade. app.get('*', function(req, res) { res.sendFile(__dirname + '/public/index.html'); }); ...

How can I integrate JavaScript into Django in order to execute three separate functions?

I stumbled upon this question that seems like it could solve my issue, however, I lack knowledge in javascript. In my views.py file, I have 3 functions that I want to execute, but due to using (forms.Form), I am facing difficulties running these functions ...

Troubleshooting Bootstrap's Height Problem

After extensively searching this forum, I couldn't find a solution to my bootstrap issue. Here's the code for two forms on my page: <div class="row justify-content-md-center"> <div class="col-sm-6"> <f ...

Moving the search box of a Jquery Datatable to a new location

Is it possible to reposition the filter box outside of the jQuery data table and make it look like this? What steps do I need to take to achieve that? ...

Is there a way to alter the background color of the screen with a JavaScript function?

I am struggling to create a basic button that will change the background color using a JavaScript function. Unfortunately, I can't seem to get it to work... <!doctype html><html> <head> <title>New Page</title> <sc ...

What is the process of invoking a function from a different component in Vue 3?

I attempted to use the $on method and this.$root.$refs.compname_component = this;, but encountered some errors. Please see my code below: formComponent.vue <template> <div v-if="showForm"> create Form </div> </templa ...

Add a fresh listing arranged alphabetically using either JavaScript or jQuery

I currently have a set of lists that are already alphabetically sorted. For example: <ul> <li><a href='#'>Apple</a></li> <li><a href='#'>Banana</a></li> <li><a href=& ...

Ensure the backslashes are removed from the AWS Lambda string API response

I have an AWS Lambda function where I am sending a string as my final response let abc= `"phone_exist":"0","calls":"0","lastaction":"0"` callback(null,abc); Output: "\"phone_exist\":\"0\",\"calls\":\"0\",\"l ...

Exploring Objects within an array using Angular loops

Hey there, I'm currently working on an Angular project and I need to retrieve the userName of the user for each comment that is posted. These entities are coming from my Spring Boot project. Is there a way to access the username for every comment? He ...

Retrieve the chosen identification from a dropdown menu (select box) with jQuery

I've been on a quest to find a solution for extracting the id from a selected option in a dropdown list. After extensive research, I stumbled upon this helpful resource: Get selected text from a drop-down list (select box) using jQuery I attempted t ...

Growing background picture

I currently have an iPad serving as a background image. However, I desire for it to be expandable, with the possibility of it being integrated into the header, footer, and the middle section expanding as needed to fill the entire page. I am open to any a ...

Include the component with the function getStaticProps loaded

I am currently working on a project using NextJs and I have created a component to load dynamic data. The component works fine when accessed via localhost:3000/faq, but I encounter an error when trying to import the same component into index.js. It seems l ...

Tips for adding information into a designated DIV using JQUERY

Having a bit of trouble with my JQUERY at the moment. Basically, I have this Facebook-style layout for displaying posts. Each post has an <input> box where members can leave comments. When a user presses <enter>, my jQuery (AJAX) will fetch th ...

What could be the reason why the navbar ul li a instance is not appearing in Bootstrap 4 modal when using an

Can anyone help me solve the issue I'm having with viewing HTML in a Bootstrap 4 modal? Everything shows up except for the navbar ul li a elements. I've searched for a solution everywhere, but haven't found one yet. Please assist! (I want t ...

The dynamic sidebar menu in Adminlte 3 with bootstrap-4 loaded from ajax is not functioning properly, presenting issues with sidebar

Is there a way to fetch dynamic sidebar menu data from the database using AJAX in the adminlte 3 dashboard along with bootstrap 4? I have tried loading the sidebar menu data dynamically using AJAX, but the sidebar open/close functionality is not working pr ...

Guide to configuring eslint-webpack-plugin rules in Webpack

How can I properly configure options for the Eslint plugin with Webpack? This is what my webpack.config.js file looks like: const path = require('path'); const ESLintPlugin = require('eslint-webpack-plugin'); module.exports = { plu ...

What steps can I take to ensure that bubbles stay in place in my highcharts graphs?

I recently created a bubble chart using highcharts with the zoomType set to 'xy'. When I tried zooming out of the plot, an interesting visualization appeared. You can view it here. ...

Achieving the perfect vertical alignment of navigation buttons alongside a responsive image

Is there a way to ensure that the button always vertically aligns in the middle of the image responsively? I've managed to make the image responsive using .img-responsive, but I'm having trouble keeping the arrow centered on the image at all time ...

reinitialize function post-ajax request

I am currently in the process of rewriting a script that manipulates data attributes to rebuild a block. The original script worked fine, but now I need to implement AJAX functionality. Here is my updated script: (function($){ jQuery.fn.someItem = functio ...