Combining several btn-group and btn-group-vertical elements within each other

I am looking to create a button grid resembling a numpad for my project. I am utilizing angular and bootstrap 5 and thought of using btn-group and btn-group-vertical for this purpose.

While this setup would work for a regular button grid, I need to have two buttons, "OK" and "0," larger than the rest. I attempted to achieve this by nesting vertical and horizontal groups, but it seems that the borders are not rounding correctly with deeper nestings.

Is the nesting limited to just one level? If so, is there an alternative way to create a similar numpad without relying on Bootstrap's rows and columns with extensive CSS? Or perhaps there is another method to incorporate larger "OK" and "0" buttons in the grid?

This is what I have come up with so far:

@import url("https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a5855554e494e485b4a1753595554497a0b140b0a140f">[email protected]</a>/font/bootstrap-icons.css");
.btn {
  height: 75px;
  min-height: 75px;
}

.zero {
  width: calc(100%*2/3)
}

.decimal {
  width: 33.4%;
}
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ceaca1a1babdbabcafbe8efbe0fde0ff">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="05676a6a71767177647545302b362b34">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b4944445f585f594a5b0642484445586b1a051a1b051e">[email protected]</a>/font/bootstrap-icons.css">
<div class="container">
  <div class="row">
    <div class="col-6">
      <div class="btn-group w-100 keys">
        <div class="btn-group-vertical w-100" role="group" aria-label="Vertical button group">
          <div class="btn-group" role="group">
            <button type="button" class="btn btn-outline-secondary w-100">1</button>
            <button type="button" class="btn btn-outline-secondary w-100">2</button>
            <button type="button" class="btn btn-outline-secondary w-100">3</button>
            <button type="butoon" class="btn btn-outline-secondary w-100"><i class="bi bi-backspace"></i></button>
          </div>
          <div class="btn-group" role="group">
            <button type="button" class="btn btn-outline-secondary w-100">4</button>
            <button type="button" class="btn btn-outline-secondary w-100">5</button>
            <button type="button" class="btn btn-outline-secondary w-100">6</button>
            <button type="butoon" class="btn btn-outline-secondary w-100">C</button>
          </div>

          <div class="btn-group">
            <div class="btn-group-vertical w-75">
              <div class="btn-group" role="group">
                <button type="button" class="btn btn-outline-secondary w-100">7</button>
                <button type="button" class="btn btn-outline-secondary w-100">8</button>
                <button type="button" class="btn btn-outline-secondary w-100">9</button>
              </div>

              <div class="btn-group" role="group">
                <button type="button" class="btn btn-outline-secondary zero">0</button>
                <button type="button" class="btn btn-outline-secondary decimal">,</button>
              </div>

            </div>
            <div class="btn-group-vertical w-25">
              <button type="button" class="btn btn-outline-secondary h-100">OK</button>

            </div>
          </div>

        </div>
      </div>

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

Answer №1

After experimenting with a dummy-div-element and manipulating the positioning and height of the enter-key-element, I was able to achieve the desired outcome:

:root {
    --height: 75px;
}

.btn {
    height: var(--height);
    min-height: var(--height);
    width: 25%;
}
.enter {
    position: relative;
    top: calc((var(--height) - var(--bs-border-width)) * -1);
    height: calc(var(--height) * 2 - var(--bs-border-width));
    min-height: calc(var(--height) * 2 - var(--bs-border-width));
    margin-left: calc(var(--bs-border-width) * -1);
}
...

To maintain flexibility in the design, I utilized a css-variable to control the height and related calculations.

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

Customizing Material UI tooltip styles with inline CSS formatting

Currently in the process of creating a React component that utilizes the Material UI Tooltip feature. In my component, I have the need to manually reposition the Mui Tooltip by targeting the root popper element (MuiTooltip-popper). However, the Mui Toolti ...

Adding material-ui library to a stylesheet

Can I include @material-ui/core/colors/deepOrange in my CSS file? I want to import this library and use it as shown below: import deepOrange from '@material-ui/core/colors/deepOrange'; import deepPurple from '@material-ui/core/colors/deepPu ...

SyntaxError: The input on line one ended unexpectedly and was not caught

This issue is commonly associated with messy close parentheses, however, the error is occurring on line 1 of the file! Below is the javascript code from (filename: calculate.js) var colors = new Array(); colors["SILVER"] = -2; ... Although there is m ...

Exploring CSS Outlining in Visual Studio 2013

Back in the days of Visual Studio 2010, whenever you opened a CSS file, a window would automatically pop up displaying all the classes and IDs for easy navigation within the file. However, in Visual Studio 2013, I seem to be unable to locate this helpful ...

Is jQuery failing to respond after being transferred from HTML to PHP?

The debug message from the Venkman debugger reads as follows: $("#aboutbox") is null [Break On This Error] $("#aboutbox").hide(); I'm at a loss on how to resolve this issue! It was functioning perfectly in HTML: But after transitioning it to PH ...

setting the width of <input> fields to automatically adjust

Curious about CSS. I was under the impression that setting width:auto for a display:block element would make it 'fill available space'. However, when applied to an <input> element, this doesn't seem to hold true. For instance: <b ...

Concerns with the adaptability of CSS grid rows

I'm struggling to find a solution for the issue I am facing. Is there a way to adjust each column's row height based on its content in a way that differs from the other column rows? The code snippet below demonstrates the current setup, which is ...

Is your margin not functioning correctly? Is padding taking on the role of margin?

One issue I'm encountering is that the margin isn't behaving as expected in this example. The padding seems to be working like margin should. Why is that? Print Screen: https://i.stack.imgur.com/N1ojF.png Why is it that the margin in the h3 ta ...

Guide on how to use a tooltip for a switch component in Material-UI with React

I am attempting to incorporate a tooltip around an interactive MUI switch button that changes dynamically with user input. Here is the code snippet I have implemented so far: import * as React from 'react'; import { styled } from '@mui/mater ...

What is the best method for automating the transfer of data from a database to the user interface of a website using html and javascript?

As a volunteer coordinator for a non-profit organization, I have some basic experience working with Python. I am willing to dedicate fewer than 8 hours of learning time to my current project in order to automate certain tasks (or else I will do them manual ...

The intended functionality of clicking on an image is exclusively reserved for its immediate parent element

I have a feature on my website that displays an image gallery. When a user clicks on an image, it opens up the image in full screen similar to Facebook's theatre mode. I have written code so that when the user clicks anywhere in the container of the i ...

Website form phone number verification server

I am currently working on developing a website form where users can input their information, including their phone number. I am looking for a simple way to verify the user's phone number using PHP without the need for installation of SDKs or complex c ...

What is the best way to use jQuery to retrieve information from one child element in an XML API in order to locate another child

Hi there, I'm new to jQuery and could use some help. I'm attempting to retrieve specific information like CPU and RAM details from a particular phone model. I've written the jQuery code, but I'm having trouble displaying the RAM and CPU ...

Within a <div> element, there is a <span> element with a border and a specific line height. The

Can anyone explain why the border of the span is positioned next to the top? When I remove the display property for the span, it seems to work fine. Thank you. div { height: 80px; border: 1px solid green; line-height: 80px } .inner-span { heigh ...

After trying out the demonstration on the website, I am unable to get my submit button to work

Having trouble with my Formsubmit feature. Despite following the example on the website, my submit button doesn't send anything and the verification isn't reaching my email. Currently working with Angular. <form action="https://formsubmi ...

How come the h2::after element is positioned directly beneath the main h2 element, and with a margin-bottom?

I'm puzzled as to why the margin-bottom property in the main h2 element isn't affecting its "::after" element. Both are defined as block elements, so one margin should provide enough space between them. Even though the "h2::after" element has 0 m ...

What is the method in PHP to send an HTML file along with a value in response to a POST request?

I have a PHP file where I want to include a dropdown list and submit button. The dropdown list should display filenames for the user to choose from. Once the user selects a filename from the dropdown list and clicks the submit button, the PHP file should r ...

Make sure to specify the max width of the Bootstrap container class to 940 pixels

Currently, I am utilizing Bootstrap 4 with the default container width on my desktop screen. For the main content section of my application, I would like it to be contained within a maximum width of 940px on larger screens. Should I override the existing ...

Guide on creating 2 select inputs with distinct elements?

Imagine you have two select inputs called 'Favorite Fruits' and 'Least Favorite Fruits'. Both of them contain a list of 5 fruits. // The following code is an example to demonstrate the issue <select name='favoriteFruits'& ...

Utilizing inter-process communication in Electron to establish a global variable from the renderer process

renderer.js ipcRenderer.sendSync('setGlobal', 'globalVarName').varInner.varInner2 = 'result'; main.js global.globalVarName = { varInner: { varInner2: '' }, iWontChange: ' ...