ghostly indentation post resizing

Can you please explain the mysterious appearance of ghostly indents upon clicking when the height is set to 0? These indents only become visible after the dropdown opens and the height is subsequently adjusted to zero. Also, what causes the jerky animation effect? Removing the scale stops the twitching animation but leaves behind phantom indents of approximately 1px (what could be causing this?). This anomaly is most prominent at a resolution of 1360x768. https://i.sstatic.net/qqbvf.png

<!DOCTYPE html>

<head>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a7d1d2c2e7958991899695">[email protected]</a>/dist/vue.js"></script>
</head>

<body>
  <div id="vue">
    <div class="select">
      <div class="main" @mousedown="isDropped = !isDropped">
        <div class="option-main"></div>
      </div>

      <div class="dropdown" v-dropped>
        <div class="container">
          <div class="option">
            <span>English</span>
          </div>
          <div class="option">
            <span>Русский</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
<style>
  body {
    background: green;
  }

  .select {
    width: max-content;
    height: max-content;

    transform-origin: top left;
      transform: scale(16);

    background: white;
    position: relative;
    font-size: 1.6vmin;
  }

  .main {
    width: 100%;
    box-sizing: border-box;
    height: 2vmin;
    display: flex;
    align-items: center;
  }

  .option-main {
    display: flex;
    height: 2vmin;
    width: 100%;
    background: white;
  }

  .option {
    display: flex;
    height: 2vmin;
    width: 100%;
    background: red;
  }

  .dropdown {
    height: 0;
    overflow: hidden;
    transition: height 1s ease;
    background: white;
  }

  .container {
    overflow: hidden;
  }

  .option-selected {
    background: red;
  }
</style>
<script>
  let myVue = new Vue({
    el: "#vue",
    data: {
      isDropped: false,
    },
    directives: {
      dropped(el, binding, vnode) {
        if (vnode.context.isDropped) {
          el.style.height = el.firstChild.scrollHeight + "px";
        } else {
          el.style.height = 0;
        }
      },
    },
  });
</script>

</html>

Answer №1

The .select element should have the CSS property overflow: hidden:

.select {
  overflow: hidden;
}

<!DOCTYPE html>

<head>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f494a5a7f0d1109110e0d">[email protected]</a>/dist/vue.js"></script>
</head>

<body>
  <div id="vue">
    <div class="select">
      <div class="main" @mousedown="isDropped = !isDropped">
        <div class="option-main"></div>
      </div>

      <div class="dropdown" v-dropped>
        <div class="container">
          <div class="option">
            <span>English</span>
          </div>
          <div class="option">
            <span>Русский</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
<style>
  body {
    background: green;
  }

  .select {
    overflow: hidden;
    width: max-content;
    height: max-content;

    transform-origin: top left;
      transform: scale(16);

    background: white;
    position: relative;
    font-size: 1.6vmin;
  }

  .main {
    width: 100%;
    box-sizing: border-box;
    height: 2vmin;
    display: flex;
    align-items: center;
  }

  .option-main {
    display: flex;
    height: 2vmin;
    width: 100%;
    background: white;
  }

  .option {
    display: flex;
    height: 2vmin;
    width: 100%;
    background: red;
  }

  .dropdown {
    height: 0;
    overflow: hidden;
    transition: height 1s ease;
    background: white;
  }

  .container {
    overflow: hidden;
  }

  .option-selected {
    background: red;
  }
</style>
<script>
  let myVue = new Vue({
    el: "#vue",
    data: {
      isDropped: false,
    },
    directives: {
      dropped(el, binding, vnode) {
        if (vnode.context.isDropped) {
          el.style.height =
            el.firstChild.scrollHeight + "px";
        } else {
          el.style.height = 0;
        }
      },
    },
  });
</script>

</html>

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

Newly developed Node.js code to comply with the EcmaScript 2015 standards

As of April 26, 2016 or later, with the release of Node.js 6+, there is a 96% compatibility with EcmaScript 2015. You can check out more information on Node.js EcmaScript 2015 support here. Is using Babel still the most effective way to bridge that remain ...

Sending state information through props in a Vuex environment

One of the challenges I am facing is how to make a reusable component that can display data from the store. My idea is to pass the name of the store module and property name through props, as shown below: <thingy module="module1" section=" ...

Generate a spreadsheet file in xlsx format by using the exceljs library in Node

I am currently working with exceljs 3.8 in an attempt to generate a new XLSX file, but unfortunately the code below seems to be malfunctioning. createNewExcelFile: function (excelFilePath) { //excelFilePath: Path and filename for the Exce ...

v-autocomplete not displaying full list of items in selection dropdown

I have a question regarding sending an array with values ranging from 1 to 100 on the v-autocomplete item props. However, when scrolling through the list, only numbers up to 40-50 are visible. <template> <v-app> <v-container> ...

Should I refrain from storing user files on my server?

Greetings! I am currently working on an Express js + React js application and using MySQL for database management. I have successfully stored user information like email, hashed passwords, and user IDs in the database. However, now I want to create ...

Is it feasible to execute exe files within a ReactJS environment?

Hey there! I've created a Game Launcher using ReactJS for my Unity game and was wondering if it's feasible to start the game (an exe file) simply by clicking on the play button. Can anyone please advise me on this? ...

The PHP sorted array loses its order when encoded into JSON and then sorted in JavaScript

In my PHP code, I have two arrays that I need to work with. The first array is sorted using the arsort() function like this: arsort($array1); After sorting, I output the contents of both arrays like so: foreach ($array1 as $key => $val) { $output ...

Inter-service/module communication on a widget interface

We are in the process of creating a widget screen that contains various widgets/modules: Products: Displays a list of products Product Details: Retrieves product details from the server when a selection is made in the "Products" widget. Related Products: ...

Looking for a way to easily swipe through videos?

My mobile phone viewport displays a series of pictures and videos, with the swipeleft/right function enabled for browsing. However, I noticed that while the swipe feature works fine for images, it stops functioning when a video is displayed. Can anyone p ...

What is the best method to update the content of a bootstrap-5 popover using only pure JavaScript?

Having trouble changing the content of a Bootstrap popover using vanilla JavaScript? The code seems to be updating, but the changes are not reflecting on the site. Any suggestions or alternative methods would be greatly appreciated! Maybe there's a di ...

How can JSON data be passed to the Google Charts API?

I am currently working on a project that involves retrieving JSON data from a website and visualizing it on a live graph using the Google Charts API. Despite my efforts, I am unable to get the chart to display properly. Can someone please guide me in the r ...

Proper method for incorporating a single database pool across an Express application

Disclaimer: This issue pertains to singleton objects in Node.js and not DB pools. While developing an Express.js application with the mysqljs node module for DB connections, I am interested in creating a single pool object that can be reused across differ ...

Unidentified entity triggering an error in the console

It seemed like there wasn't anything quite like this before... at least not that I could understand with my limited experience. I was experimenting with creating a global object that contains methods, including instructions for handling AJAX requests ...

Sharing data between child and parent components, and then passing it on to another child component in React Js

I have a scenario where I am passing props from a child component B to parent component A, and then from parent component A to child component C. Everything works fine when I pass the data from component B to A, but I encounter an issue when I try to set a ...

Tips for transferring a form using Ajax and PHP

Just starting out with this project and hoping for some help. I need to get a simple code working first before making any modifications. Currently, the echo function is not showing anything on the page after submitting the form. My goal is to submit a form ...

Adapting iFrame height to accommodate fluctuating content height in real time (details included)

I have an embedded iframe that contains a form with jQuery validation. When errors occur, the content height of the iframe increases dynamically. Below is the script I use to adjust the height of my iframe based on its content: function doIframe(){ o = d ...

Can you explain the distinction between the terms "vite" and "vite preview"?

I recently created a project template with the help of vite. While looking through my package.json file, I noticed the following section; "scripts": { "dev": "vite", "build": "vue-tsc --noEmit &&a ...

Tips for sending event and additional arguments to a click handler

Hi there, I recently created a canvas using easelJS. Within my canvas, I have points that have a click handler defined for them with this syntax: p.on("click", handleMouseClickEvent); However, I am facing an issue when trying to pass arguments to the han ...

What is the most efficient way to organize JSON data in a tree structure using JavaScript?

I have a JSON data structure that I need to transform into a different format. The original JSON format: values = an array containing objects that need to be filtered by action === 'commented' comment = an object with the comment, n Tasks, and ...

Is there a way to verify Page.Validate() using client-side JavaScript in ASP.Net?

Is there a client-side function in JavaScript that can perform page validation similar to the server-side method Page.Validate()? ...