Creating a unique Web Component that spans the full height of the page

I created a Web Component with Vue.js and vue-custom-element. I now want my my-chat and my-whiteboard Web Components to have a height of 100%. Here's how I'm using the component:

// App.vue
<template>
  <splitpanes class="default-theme">
    <pane>
      <my-chat></my-chat>
    </pane>
    <pane>
      <my-whiteboard></my-whiteboard>
    </pane>
  </splitpanes>
</template>

The only solution I know is setting the height of all parent elements to 100% like this:

html,
body,
splitpanes,
pane,
my-chat,
my-whiteboard {
    height: 100%;
}
//main.js

...
// Load custom element plugin
Vue.use(vueCustomElement);

// Define web components
Vue.customElement("skyroom-whiteboard", Whiteboard);
Vue.customElement("skyroom-chat", Chat);
...

And you have to do this for all tags inside the my-chat and my-whiteboard as well!!!

The issues I face are:

  1. This method does not work for my- components.
  2. It seems incorrect! Is there a correct way to achieve this?

Answer №1

One way to achieve this is by utilizing the following CSS:

my-chat, my-whiteboard {
  min-height: 100vh;
}

However, if one element surpasses the 100vh height limit, it will expand independently of the other. In such cases, you can try using the following CSS properties:

display: block;
height: 100vh;
overflow-y: auto;

To see a practical demonstration, consider the example snippet below (note that the CSS code after /* let's test it */ line isn't necessary for functionality, but included due to custom elements having an initial display: inline value):

my-chat,
my-whiteboard {
  display: block;
  height: 100vh;
  overflow-y: auto;
}


/* let's check it */

my-chat,
my-whiteboard {
  box-sizing: border-box;
}

tester {
  height: 200vh;
  padding: 1rem;
}
splitpanes { display: flex; }
pane:first-child { flex-basis: 75%; }
pane:last-child { flex-grow: 1; }
body { margin: 0; }
/* don't use this line in your app, it will likely break stuff
 * I used it here because I don't have any content to break! */
.default-theme * { display: block; }
<splitpanes class="default-theme">
  <pane>
    <my-chat>
      <tester>my-chat</tester>
    </my-chat>
  </pane>
  <pane>
    <my-whiteboard>
      <tester>my-whiteboard</tester>
    </my-whiteboard>
  </pane>
</splitpanes>

Please Note: If Vue transforms any components into actual <div> elements during parsing, adjust the selectors accordingly to ensure proper styling (assuming the custom elements remain unchanged).

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 Stylish Choice: Materialize CSS Dropdown Selector

I am currently integrating Materialize CSS into my application and have used media queries to ensure that the layout is responsive. However, I am facing an issue with a select dropdown element. It works fine on laptops but does not allow for selecting any ...

Is there a way to retrieve the value of a Promise?

When making a call to a Promise API for returning from an AJAX request, I would like to have the return value in the then() function structured as follows: function get_data(url, id) { return new Promise(function (resolve, reject) { xmlHttp.open("GET" ...

Expandable Grid with UI-GRID - Automatically expand a row when clicked on

I prefer not to utilize the default + icon for expanding the row. The row should expand when clicked anywhere on it. I attempted the following: HTML <div ui-grid="gridOptions" ui-grid-expandable class="grid"> Controller var app = angular.module( ...

Difficulty validating RSA signature on the server end originating from client-side Javascript

Utilizing the forge library on the client side for creating signatures looks like this: //Client Side var md = forge.md.sha256.create(); md.update(encryptedVote, 'utf8'); var pss = forge.pss.create({ md: forge ...

What causes the toggle to malfunction when clicked on, specifically when the element is assigned the JS class?

Currently, I am working on animating cards using CSS and JavaScript. Everything seems to be working fine except for one issue – the class does not get removed on the second click on the element when using this.classList.toggle('is-active');. Ca ...

What is the best way to create rounded thumbnails with the paperclip gem?

I noticed that the latest version of Basecamp is implementing this feature, you can check it out in this link. I am curious about how to replicate this in my Rails 3 application. ...

Switching the background image with a single click and reverting it back with a double click using jquery

I am working on a project with multiple div elements which need their background images to change upon clicking and revert back to the original image when clicked again. Below is the CSS code for one of the divs, including its Class and ID: .tab_box { wid ...

Chrome extension for AJAX with CORS plugin

Currently, I am utilizing jQuery for cross-origin AJAX requests and attempting to include headers in the request as shown below. However, I am encountering an error message stating that it is an invalid request: $.ajax({ url: address, headers:{ ...

Is there a way to efficiently compare multiple arrays in Typescript and Angular?

I am faced with a scenario where I have 4 separate arrays and need to identify if any item appears in more than two of the arrays. If this is the case, I must delete the duplicate items from all arrays except one based on a specific property. let arrayA = ...

The React.js component search test encounters errors in locating components

I have been working on a React app that utilizes Redux and React-router. I am currently writing tests using React TestUtils, and I encountered an issue with the following test results: The first expect statement is successful: expect(nav).to.have.length(1) ...

Invoke a function within the redux reducer

The code within my reducer is structured as follows: import {ADD_FILTER, REMOVE_FILTER} from "../../../../actions/types"; const removeFilter = (state, name) => { return state.filter(f => f.name !== name); }; export default function addRemoveFi ...

Node.js failing to log chat messages

The goal is to log the chat message entered by the user in the console (terminal). Currently, there seems to be an issue with logging and I'm struggling to debug it. Keep in mind that I am a novice when it comes to NodeJS and only have basic knowledge ...

Unexpected error 500 (Internal Server Error) occurred due to BadMethodCallException

Using Vue 2.0 and Laravel 5.4, I am working on creating a matching system that includes a dynamic Vue component. For example, when someone likes another person, it should immediately show that the like has been sent or if the like is mutual, it should indi ...

Switch the CSS class for the currently selected link

There are 5 links on the page. When I click on each link, it changes color. However, when I move my cursor to another area of the page, the active link loses focus and I can't show its current state. Can you please advise me on how to fix this issue? ...

Attempting to construct an 'or' query that relies on the combination of two distinct joined tables

Currently, I am facing a challenge with selecting rows from a PostgreSQL database through Sequelize. I need to retrieve data where the ID exists in either joined table 1 or joined table 2. In my attempts using Sequelize, I used 'include' to quer ...

Determining surface volume: Duplicate vertices found within the position array of the buffer geometry

I am currently working on calculating the surface area of a 3D model imported through the IFC Loader tool. However, before diving into the complex models, I decided to start with simpler shapes like pyramids to better understand the process. From my under ...

A picture resting on the left side of the text

I'm struggling to align images to the left of text within a div. When the screen is smaller than 768px, I want the images to stack on the left side of the text, with a maximum width of 150px. I've tried using float: left and adjusting the displa ...

Tips for retrieving the concealed input value from the div directly preceding

Is it possible for me to retrieve the hidden input value by clicking on the text "upload profile photo"? I don't have much experience in this area. <div> <input type="hidden" value='<?php echo $list['profil ...

What is the best way to connect to a SPA address?

I have a Vue application with a single page that uses hash history for the URLs, such as . Another website built using Wagtail CMS is trying to link to my Vue single page app using an anchor tag but it doesn't seem to be working. The site with the anc ...

JavaScript is able to access the HTML content of the previously opened tab when saving the window

Seeking advice from the knowledgeable community at Stack Overflow! I have a project that I'm unsure how to start, and I could use some fresh ideas. My goal is to access the HTML source code of a previously opened tab or one that is still loading on m ...