The steps to properly load "child.vue" into the correct position within "parent.vue" are as follows

Currently I am developing a single page web application using Vue.js. This app consists of 4 "page.vue" files, each with a right and left child .vue component nested inside.

For instance, the Page1.vue file is structured as follows (omitting style and script for brevity):

The child components, Page1Links and Page1Rechts, are intended to be loaded into the main section of the page. These two components were separated so that one can easily be replaced with a more complex version while keeping the other intact.

<template>
  <div>
    <div class="page-wrapper">
      <div class="page-container">
        <div class="page-header">
          <h1 id="page-h1"><span>Mauderer</span> Containertreppenkonfigurator</h1>
        </div>
        <div class="page-main-content">
          <Page1Links id="links"/>
          <Page1Rechts id="rechts"/>
        </div>
        <div class="page-footer">

        </div>
      </div>
    </div>
  </div>
</template>

I aim to have a header component spanning the full width of the page, followed by the two child components side by side, where the left component occupies 70% of the width and the right component occupies 30%. Finally, I want the footer to span the full width of the page.

However, my current layout displays all divs stacked at the top of the page in the following order: 1. header div 2. empty main div 3. footer div 4. child components (forced placement)

After attempting different design enhancements like adding box shadows, the child components still do not render within the main div but rather appear below the footer.

Upon receiving suggestions to use flexbox for better layout control, I realized that my issue lies in the rendering of child components outside of their designated main div.

If you refer to this example image, you'll notice that despite expecting the child components to render within the main part, they actually display after Page 1, below it.

Although BootstrapVue is included in my project, I may need to reconsider its usage if there's a simpler approach. Any guidance on resolving this rendering issue would be appreciated.

Answer №1

Can you show me your css code?

It seems like you want to display #links and #rechts next to each other, which can be achieved using flexbox.

.page-main-content{display: flex;}
#links{flex: 0 0 70%;}
#rechts{flex: 0 0 30%;}

Answer №2

After a few attempts, I finally got it to work and the solution was successful. However, I'm not entirely sure why it worked. The flex now pushes the children within page1 into the page-main-content.

I can see that this method is more efficient than what I previously tried (coding the size of the component within itself), but the components were originally positioned next to each other, so the flex forced the children to render inside the parent instead of below or after it.

Thank you for helping me solve the problem.

If anyone has a concise explanation, I would still be interested in understanding why this change occurred.

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

Tips for accessing the 'styled' function in Material UI ReactHow to utilize the 'styled' function

Hey there, I'm facing an issue while trying to export a styled AppBar. Check out my code below: import * as React from 'react'; import { styled, useTheme } from '@mui/material/styles'; import MuiAppBar from '@mui/material/AppB ...

Is there a way to ensure a Javascript alert appears just one time and never again?

I struggle with Javascript, but I have a specific task that needs to be completed. I am participating in a school competition and need an alert to appear only once throughout the entire project, not just once per browsing session. The alert will inform ...

What is the best way to retrieve a unique identifier from multiple arrays and store it in one shared variable?

I have an array stored locally and I need to retrieve the "name" ID from all of them. How can I achieve this using AngularJS or JavaScript? [{"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85cfeaedebc5e4abe6eae8">[ ...

Achieving Flexbox compatibility with child elements in a horizontal MUI Collapse Component and TransitionGroup transitions: A comprehensive guide

Struggling with incorporating the Collapse + TransitionGroup Component in MUI while trying to make the containers expand using flexbox. <Box sx={{display: 'flex', height: '100vh', width: '100vw'}}> <Box sx={{flex: 1 ...

"Mastering the art of traversing through request.body and making necessary updates on an object

As I was reviewing a MERN tutorial, specifically focusing on the "update" route, I came across some interesting code snippets. todoRoutes.route('/update/:id').post(function(req, res) { Todo.findById(req.params.id, function(err, todo) { ...

Tips on overriding the outline:none property in CSS

Is there a way to overwrite the 'outline: none' property in CSS? I have a parent class that has this property set, but I want to remove it in the child class. ...

Embed a React component seamlessly within HTML code

Hey there! I have a situation where I'm pulling valid HTML content from the database and I need to replace merge tags with working React components. The HTML is generated using a WYSIWYG editor. Let me give you an example: const link = <a onClick= ...

My code to hide the popup when clicking outside doesn't seem to be working. Can you help me figure out why?

After searching around on stackoverflow, I stumbled upon a solution that worked for me: jQuery(document).mouseup(function (e){ var container = jQuery(".quick-info"); if (container.has(e.target).length === 0) { container.hide(); } }); ...

What is the method used by React or Next to prevent the <a> tag from refreshing the page while still loading content?

I'm currently diving into the world of NextJS and utilizing the Link component from the 'next/link' package. One thing that has been puzzling me is how the <Link> component ultimately renders an <a> tag with a href='/tosomew ...

Utilize conditional styling in Vue using CSS

I am having difficulty implementing a conditional Vue statement to change the CSS style based on the text value. Despite trying other tutorials, I have had no success due to my limited experience with Vue. For example, if I want the class to be "is-succes ...

Having trouble with image hover functionality on pure CSS?

<div id="headermenu"> <ul > <li id="menu1"><a href="#"><img src="images/menu1.png"/></a></li> <li id="menu2"><a href="#"><img src="images/menu2.png"/></a> < ...

What is the best way to create a menu in JavaScript that includes a variable declaration?

Here is the menu I've created: <a id="page1" href="" onclick="var = page1">Home</a> <a id="page2" href="" >About us</a> <a id="page3" href="" >Services</a> <a id="page4" href="" >Partners</a> <a ...

Issue with implementing MUI Style Tag in conjunction with styled-components and Typescript

I have created a custom SelectType component using Styled Components, which looks like this: import Select from '@mui/material/Select'; export const SelectType = styled(Select)` width:100%; border:2px solid #eaeaef; border-radius:8px ...

Flask template fails to render following a redirect

I have embarked on creating a simple CARTO application using a combination of Vue JS and Flask. If you wish to explore the entire code, it can be accessed from this github repository. Here's how the application is designed to function: The user m ...

Issue with submit button functionality in Wicket when the value is empty

This is a custom class called YesNoPanel that extends the Panel class: public class YesNoPanel extends Panel { /** * */ private String password = "Password"; public String getPassword() { return password; } public void setPassword(String passwo ...

Updating table width using AngularJS/jQuery after completion of ajax request

One of my challenges involves a table that defaults to a specific width, such as 80% of its parent div. Initially, the table remains hidden using 'ng-if' until an ajax call is completed in this manner: This is reflected in the HTML code snippet ...

Prevent the use of unnecessary object properties

Currently, my project involves using Typescript and React in conjunction with Material-UI. Specifically, I am utilizing Material-UI's styling solution, which implements CSS in JS methodology in a Hook-like manner as outlined in their documentation: co ...

The problem of changing the vuex store outside of designated handlers

I wrote a getter function that extracts values from the state and returns new ones. modifiedData: state => { const data = state.modifiedData; Object.keys(data).forEach(key => { data[key]["Risk buckets"] = `(${data[key]["Risk buckets"] ...

When the Bootstrap navbar is collapsed, clicking on it does not result in it opening

I'm attempting to create a collapsible navbar for smaller screens that expands when a button is clicked. However, upon clicking the button, nothing happens and I'm unsure why. <nav class="navbar navbar-expand-lg navbar-light" style="backgro ...

Manipulating rows [using an input field] within a table

As someone new to JavaScript, I tried my hand at coding the following piece after tweaking a tutorial I stumbled upon. The aim was to have rows with input fields added and removed within a table, but unfortunately, nothing happens when running the code. ...