The flexbox layout is not properly stacking div rows in a column

Objective: Creating a flexbox layout with a responsive background image that adjusts in height when the screen size changes, causing elements to wrap; In addition, there is a fixed header bar at the top of the page.

The layout consists of a full-screen column with a background image. The first element within the column is a mock header bar. The second element should be a div with flex-direction set to row, but the colored divs inside still act as if they are in a column.

https://i.sstatic.net/ppNWA.jpg

    html, body { box-sizing: border-box; height: 100%; width: 100%;
  margin: 0; padding: 0; border: 0; cursor: default }

.workspace {
  background: url("../../../assets/Images/WhatIsHunter2.jpg") no-repeat center center fixed;
  background-size: cover;
  height: 100vh;
  width: 100vw;

  h1 {
    color: #E0B228;
  }

  h2 {
    color: #2856E0;
  }
}

The HTML:

<div class='workspace' [ngStyle]="{'display': 'flexbox', 'flex-direction': 'column'}">
  <div [ngStyle]="{'width': '100vw', 'height': '60px', 'background-color': 'beige'}">
    This row represents the header bar at the top of the column
  </div>
  <div [ngStyle]="{'margin-top': '20px', 'display': 'flexbox', 'flex-direction': 'row', 'justify-content': 'space-evenly'}">
    <div [ngStyle]="{'width': '100px', 'height': '100px', 'background-color': 'red'}">
    </div>
    <div [ngStyle]="{'width': '100px', 'height': '100px', 'background-color': 'green'}">
    </div>
    <div [ngStyle]="{'width': '100px', 'height': '100px', 'background-color': 'blue'}">
    </div>
  </div>
</div>

Answer №1

To make it work, switch from display: flexbox; to display: flex;

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

Having trouble getting two divs to align on the same line using the 'inline' method

I am struggling to align multiple buttons within divs on the same line. Two of these buttons should only be displayed when a specific value is greater than 0. I attempted using display:inline-block in a container div, along with style="float:right", but it ...

Consider utilizing divs in a similar manner to tables

I typically use tables to align images and text, but they don't work well on mobile devices. I'd like to switch to using CSS and DIVs instead, even though I have no experience with them. My goal is to center three pictures with text above each o ...

Solving Problems with Image Placement using CSS

As I embark on learning responsive CSS, the concept is still quite new to me. One issue I'm facing is the alignment of the images on the second row in comparison to the top images. I aim to have 4 images per row, with the flexibility for the image siz ...

Utilizing Angular 4 to dynamically render a template stored in a string variable

Is it possible to dynamically render HTML using a string variable in Angular4? sample.component.ts let stringTemplate = "<div><p>I should be rendered as a HTML<br></p></div>"; The contents of the sample.component.html s ...

A straightforward development and production build to incorporate HTTPS for a static website created with React and Express

Is there a straightforward method to create a static web page and Node backend where the Node server runs in HTTPS during development but not in production? How can the static web page point to https://localhost/foo in dev mode, and simply /foo in producti ...

When I upload the landing page through cpanel, none of my CSS files appear to be active

I am having an issue with my webpage at . Everything looks great when I view it on my local host, but once I upload it, the CSS files and images are not loading properly. Can anyone assist me with this problem? ...

Enhancing URLs with jQuery/AJAX: A Comprehensive Guide to Adding Parameters

Whenever I try to use the get method on an HTML form, the submitted data automatically appears in the URL. You can see what I mean here. Interestingly, when attempting to achieve the same result with JQuery and AJAX using the get method, the data doesn&apo ...

Modify the default background color for the chosen element in the tree structure

Could someone assist me in changing the default background color of a selected element in the tree? Below is the XHTML code: <style type="text/css"> .ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state- ...

Dynamic Variable Translation in Angular 8 using i18n

Within my app.component.html, there is a recurring element on every page: <h1 i18n="@@titleH1">{{title}}</h1> I created a shared service with setters and getters: ... title = new BehaviorSubject('Initial Title'); setTitle(title: s ...

Vue JS nested component does not appear in the document object model

I developed two separate VueJS components - one displaying a modal and the other featuring HTML input fields. When I attempt to nest these two components, the inner component fails to appear in the DOM. What could be causing this issue? Here's a snip ...

Expanding the navbar with Bootstrap 3.0 by using the navbar-brand class

I'm facing an issue with the navbar-brand while adding my logo. I am using the latest version of bootstrap CSS from getbootstrap.com, and the problem is also evident there: The navbar becomes slightly oversized when the logo is included. However, if I ...

How can I create a box-shaped outline using Three.js?

As someone new to threejs, I have been trying to figure out how to render a transparent box around a symbol in my canvas. The box should only display a border and the width of this border should be customizable. Currently, I am using wireframe to create a ...

Material UI defaults remain unchanged despite any emotional influence

I'm currently experimenting with custom styling on a MaterialUI Typography component using the code snippet below: const StyledTitleTypography = styled(Typography)` color: 'black'; font-weight: 'bold'; `; <StyledTitleTypogr ...

Tips for transferring parameters using a href tag without causing a page refresh

Is there a way to pass parameter values without refreshing the page? I would appreciate any help. Thank you. searchresult.php <a href="index.php?id=<?php echo $data['ID']?>">clickme</a> index.php <?php echo $_GET['id ...

Receiving HTTP POST data using Classic ASP script

I'm currently working on a project and have come across an area where I am facing some challenges. Despite my best efforts, I haven't been able to find a solution using Google. In my ASP web application, I've added an HTML canvas that I nee ...

Is there a way in Jquery to remove a class?

I have created a code for a single page website where clicking on the toggle bar will display the 'ul' and clicking on one of the 'a' links will take me to the corresponding div. I want the toggle bar to automatically close back after c ...

Unable to retrieve form data from Angular node MongoDB

Currently, I am facing an issue with my application that is designed to input contact information such as first name, last name, and phone number into MongoDB. Interestingly, when using Postman, the data is successfully added without any problems. However ...

Discovering the tab index of a tab header in Angular 4 Material

In my Angular application, I am using a mat-tab component to display tabs dynamically generated from an array. The template looks something like this: <mat-tab-group> <mat-tab *ngFor="let tb of dynTabs"> ...

Bypassing disputes in a TypeScript function

I attempted to implement the solution provided by Pacerier in response to the question about skipping arguments in a JavaScript function. However, it doesn't seem to be working for me. The function I am dealing with has numerous arguments. this.servi ...

A Guide to Effectively Managing Express API Responses in Angular 2

When I make an Express API call from my Angular 2 application, I receive a response in the following way. In my component: this.emailService.sendEmail(this.name, this.email, this.message) .subscribe( (res) => ...