Adjusting the height of a flexbox column to fit three rows within the space of two

Exploring the wonders of Flexbox and delving into its functionality. I have shared a Code Sandbox link showcasing my React /bootstrap code in progress... Currently, I am developing a clock component with two buttons for adjusting time (increase/decrease). Visual representation can be found below:

https://i.sstatic.net/TtMlW.png

The height of this component suits me perfectly at this stage. However, I wish to incorporate three rows of buttons (Start, Pause, 1st) in a separate column adjacent to the clock. My aim is to make this second column adjust its height according to the clock's height on the left. Unfortunately, my current output differs from my expectations as shown here:

https://i.sstatic.net/jWNYs.png

I've experimented with utilizing two flexboxes but struggle with aligning their heights accordingly. How can I effectively achieve this synchronization between columns?

Answer №1

Utilizing the power of flexbox, accomplishing this task becomes a breeze.

In the code snippet below, you can observe that I have successfully replicated your specifications.

However, the buttons positioned above and below are currently spaced out to align with the three buttons on the right side.

If your intention is to occupy the entire space with the two buttons, you can adjust their padding to match the column of three buttons.

* {
  box-sizing: border-box;
}

.wrapper,
.clock-wrapper,
.action-wrapper,
.btn-wrapper {
  display: flex;
}

.btn-wrapper button {
  padding: 5px 10px;
}

.action-wrapper,
.btn-wrapper {
  flex-direction: column;
  justify-content: space-between;
}

input {
  height: 100%;
  font-size: 30px;
  width: 100px;
  font-weight: bold;
  text-align: center;
}
<div class="wrapper">
  <section class="clock-wrapper">
    <div class="btn-wrapper">
      <button>Up</button>
      <button>Down</button>
    </div>
    <div>
      <input type="text" value="10:35" />
    </div>
    <div class="btn-wrapper">
      <button>Up</button>
      <button>Down</button>
    </div>
  </section>
  <section class="action-wrapper">
    <button>Start</button>
    <button>Reset</button>
    <button>1st</button>
  </section>
</div>

Answer №2

.button-group button {
  height:50%
}

To align the up and down buttons with the clock height, include this code.

The class 'button-group' sets the height using flexbox, which is correct, but the buttons should also have a height that matches the 'button-group' container.

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

Understanding and aggregating data from JSON files

I am in possession of a group of json values outlined below {"labels":[ "time", "softirq", "user", "system", "nice", "iowait" ], "data":[ [ 1490088352, 0, 14.64646, 3.53535, 0, 1.0101 ], [ 1490088351, 0, 27.77778, 3.0303, 0, 0 ], [ 1490088350, 0.49751, 12 ...

Custom CSS file for individual tenants in the Twig main template

Our Symfony 2.4 application is a multi-tenant system, meaning we share the same codebase among several organizations and differentiate access by domain name. For example: organization1.domain.com organization2.domain.com organization3.domain.com We util ...

Switching off toggle does not switch back to primary theme when clicking again for the second time

When I click the button for the first time, it changes the theme. However, when I click it a second time, nothing happens; it seems like it's stuck on the second theme forever. It should change themes with every click. Can someone please help me with ...

JavaScript: Obtaining the month based on the week number and year

Can someone assist me in determining the month based on a given week number and year? For example: Week - 48 Year - 2023 Desired Output - 11 ...

Implementing an Onclick function in HTML

I have an HTML code and I am looking to add an onclick event for a button named GET DATA. When the button is clicked, I want to send data for userId and categoryId to a PHP file. Can someone help me implement this functionality in my existing code? Here ...

Updating React JSX class based on certain conditions without manipulating the actual DOM

When working with jsx react, I am looking to dynamically set a class while keeping another class static. Here is an example of what I would like to achieve: maintaining the type class and having an additional dynamic class change change to either big, smal ...

Converting JavaScript variable values to PHP variables by extracting the content of a textarea

Currently, I'm developing a data filtering mask which triggers when the button <input type="button" /> is clicked. In this process, I have: School classes (1, 2, 3, 4, 5) Sections (A, B, C....Z) Checkboxes for male and female sexes. This ma ...

Create a path on the Google Map that follows the designated route

I am looking for a solution similar to one found here: Sample However, I have been unable to find a suitable solution anywhere. The main issue is being able to follow the route in order to draw a line between two points. Can anyone provide guidance on ho ...

Methods for setting the value of a scope variable within a controller's function

I have a goal of presenting a page that calculates a balance in the background and displays it. To achieve this, I decided to separate the balance into its own directive. Here is the directive I have created: app.directive('smBalanceInfo', fun ...

How do I make the YouTube Grid Gallery player show up in a pop-up window?

I have been experimenting with the following code: <head> <script type="text/javascript" src="http://swfobject.googlecode.com/svn/trunk/swfobject/swfobject.js"></script> <script type="text/javascript"> function loadVideo(playerUrl, ...

Utilizing JavaScript and jQuery libraries in conjunction with periods

I am a bit puzzled about when to include the period before referencing class names. For instance, in this code snippet, why is a period included before the first use of the 'active-slide' class but not for the other two instances? var primary = ...

The useRef value is not defined when used inside the useEffect function

I'm confused about the behavior of useEffect. The documentation says it runs after HTML elements are rendered, so why am I getting an undefined value for the useRef hook inside the useEffect function? How can I use useEffect to set the value of an Inp ...

Attempting to replicate the flipping motion of a card by applying the transform property to rotate a div element, ultimately revealing a different

I am attempting to create a series of divs that simulate the flipping action of a notecard. Unfortunately, when I hover over the div, it turns white because I have set the display property to none. I am unsure how to make the other div (.back) visible. Y ...

Vue and Jexcel: maximizing efficiency with event handling and dynamic calculations

I am trying to utilize the vue wrapper for jexcel and want to trigger the undo function from the toolbar computed field. However, I am facing difficulties accessing the spreadsheet instance as it throws an error saying 'this.undo is undefined.' ...

Is it possible to implement a Cross-Domain iframe Resizer in NextJS?

I am facing a challenge with my NextJS project that will be loaded within an Iframe. The page's content is dynamic, and its height changes frequently. Rather than relying on scrolling, I would like the Iframe to automatically adjust its height based o ...

Tips for implementing dynamic image paths in Next.js

As a newcomer to ReactJS and working with Next.js, I am currently fetching images from a database using an API. The issue I am facing is that I am receiving the image name with the full path (url.com/imagename), but I want to be able to use a dynamic pat ...

Customize your Material UI theme colors with SASS variables

I am exploring the idea of customizing the theme of Material UI in a dynamic way by incorporating SASS Variables that would update the Material UI theme automatically. When designing my page with Sass, I typically use variables to define colors: $primary ...

Retrieving information from the API to populate a child component in Next.js

I have been developing a header component and here's the code snippet: import style from '../../styles/header.css'; import '../../styles/globals.css'; export default function Header({data}){ const [showMe, setShowMe] = useStat ...

Restrict the number of labels on Chart.js exclusively for smaller displays

How to Limit the Number of Labels on a Chart.js Line Chart I am looking for a way to decrease the number of labels on my line chart only when it is viewed on a small device. The solution provided in the previous post suggests using the following code: xAx ...

It is not possible to decrease the size of the image that is currently used as the background image

Three images are arranged in this manner: https://i.stack.imgur.com/u4PdK.png The HTML code for this setup is as follows: <div class="lb-controlContainer"> <div class="lb-closeContainer"> <a class="lb-close"&g ...