Struggling to align 6 columns within a div while keeping the buttons centered

I am currently working on customizing my app using an Angular Material Tab. My goal is to have 6 centered buttons inside the tab, but I'm encountering issues as they are not aligning properly and end up appearing horizontally.

Image - View of my tab and the buttons

.ButtonZone{

  display: table;
  width: 100%;


}

.column {

  float: left;
  width: 15%;
  padding: 5px;

}


#blue{
  background-color: blue;

}

#yellow{
  background-color: yellow;
}
#pink{
  background-color: deeppink;
}

#red{
  background-color: red;
}
#green{
  background-color: green;
}

#grey{
   background-color: grey;
}
button{
  height: 20px;
  width: 20px;
  border: 0;

}
<div class="ButtonZone">
<div class="column">
  <button id=blue></button>
</div>

<div class="column">
  <button id=yellow></button>
</div>

  <div class="column">
    <button id=pink></button>
  </div>

  <div class="column">
    <button id=red></button>
  </div>

  <div class="column">
    <button id=green></button>
  </div>

  <div class="column">
    <button id=grey></button>
  </div>


</div>

Despite my efforts, the buttons remain on the left side of each column instead of being centered. I've experimented with various solutions but haven't achieved the desired result.

Notably, the columns seem to leave a right space (as shown in the image) even when set to width: 100%.

If anyone has suggestions or can provide guidance on how to resolve this issue, I would greatly appreciate it.

Answer №1

Ensure that you include text-align: center; in your column class. Also, don't forget to add width: 90% to your ButtonZone and use margin: auto; to perfectly center the entire group.

.ButtonZone {
  width: 90%;
  margin: auto;
}

.column {
  float: left;
  width: 15%;
  padding: 5px;
  text-align: center;
}

Check out this example on CodePen

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

Use the .html() function to alter the content of several sets of radio buttons simultaneously by changing

Here are the different options for a product. I need help with the .change() syntax to update pricing based on the following calculations: Bundle One + Marble Color = 15$ Bundle One + Black Color = 18$ Bundle Two [Most Popular] + Marble color = 25 ...

How can I center align my loader inside app-root in Angular2+?

I've successfully added a basic spinner to my <app-root> in the index.html file. This gives the appearance that something is happening behind the scenes while waiting for my app to fully load, rather than showing a blank white page. However, I& ...

Using BeautifulSoup to Retrieve JPEG from an Image Tag's Src Attribute

Struggling with scraping this webpage for personal use. I am having trouble extracting the thumbnails of each item on the page. Despite being able to see image tags containing the required .jpgs when using "inspect" to view the html DOM, I cannot find the ...

What is the best way to adjust inline svg to the user viewport size?

After working on integrating my interactive SVG maps into my HTML pages, I encountered a minor issue: when inserting my inline SVG into a standard, non-responsive HTML document, it automatically adjusts itself to fit nicely within the user's viewport. ...

What steps are involved in building a modal pop-up in Angular without using any pre-existing libraries

I am looking to create a modal popup when a button is clicked. I want to achieve this without relying on any additional dependencies. The method I have used below successfully creates a fully functional modal, but I am unsure if this is the best way to do ...

Tips for assigning dynamic #id(*ngFor) and retrieving its value in Angular2

In my HTML file, I have the following code snippet: <tr *ngFor="let package of packages"> <td *ngFor="let coverage of coverages"> <input type="hidden" #dynamicID [value]="coverage.id"> <-- Include an identifier with the vari ...

When XML is accessed through an iframe, it is interpreted as HTML

In my endeavor to display an xml file within an HTML page using an iframe and altering the content through jQuery by manipulating the source attribute, I encountered a curious issue. When I viewed the xml file directly in my browser (Firefox/Chrome/IE8), i ...

Utilizing a variable in one function within a separate function (Guide to Calculating Combinations)

As a beginner in JavaScript, I'm struggling with using a variable from one function in another function. My current project involves creating a combination calculator, but I'm facing issues with getting the output when using this script code. ...

Leveraging JavaScript Functions in HTML

I am having an issue with a JavaScript file containing two similar functions that are executed through an HTML form. While the first function runs smoothly, the second function does not display correctly. It seems like I might be calling or executing the ...

The toggle button in the navbar takes its time to vanish completely

Every time I try to close my navbar, it seems to take forever for the navbar to disappear. Below is the code snippet: HTML <!-- logo --> <div class="logo"> <img src="assets/logo.png" alt="logo g's s ...

Guide on displaying a real-time "Last Refreshed" message on a webpage that automatically updates to show the time passed since the last API request

Hey all, I recently started my journey into web development and I'm working on a feature to display "Last Refreshed ago" on the webpage. I came across this website which inspired me. What I aim to achieve is to show text like "Last Refreshed 1 sec ago ...

Tips for positioning a button directly under a horizontal navigation bar

How can I center a button just below a horizontal navigation menu, without overlapping the menu items and ensuring proper spacing when the menu expands? <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> < ...

What is the best way to incorporate a gratitude note into a Modal Form while ensuring it is responsive?

Currently, I have successfully created a pop-up form, but there are two issues that need fixing. The form is not responsive. After filling/submission, the form redirects to a separate landing page for another fill out. Expected Outcome: Ideally, I would ...

integrating a CSS file into a Vue project

As a newcomer to Vue, I encountered some difficulties understanding how things function in Vue. One of the obstacles I faced was integrating my own custom CSS file into a project. I attempted to create a file called style.css within the src folder and add ...

Arranging CSS elements in a stacked manner with fixed or absolute positioning

#snackbar { min-width: 350px; /* Default minimum width */ margin-left: -125px; /* Center value of min-width */ background-color: #333; /* Black background color */ color: #fff; /* White text color */ text-align: center; /* Cen ...

Dynamically highlight a MySQL table based on user preferences and store this information permanently

I'm working on a project that involves creating a table with highlight options on each row. The table is generated dynamically from data retrieved from MySQL. Currently, when a user selects a color from a drop-down menu, the color of the row changes a ...

Tips for displaying data by using the append() function when the page is scrolled to the bottom

How can I use the append() function to display data when scrolling to the bottom of the page? Initially, when you load the page index.php, it will display 88888 and more br tags When you scroll to the bottom of the page, I want to show 88888 and more br ...

animation frames delay for intervals

Can the animation-delay be applied not just at the start but also during iterations? For instance, consider this example: .lv1 { width: 200px; height: 200px; background: red; animation: flu 1s infinite; animation-delay: 2s; } .lv2 { backgro ...

Display multiple values in a select dropdown using Bootstrap 5 properties

I am stuck with the following code<hr> HTML <select id="select" placeholder="Choose Select" class="selectpicker" multiple></select> <div class="container"> <div id="all" clas ...

Arrange documents according to the final two characters

My method for collecting files from a folder involves using some Smarty code: {assign var=files value="uploads/Documenten/GPS-Tracks/*.html"|glob} {if count($files)} <ul> {foreach from=$files item='file'} {assign v ...