Ways to display buttons next to each other rather than in a vertical arrangement

Looking for help with a table layout - trying to get buttons displayed side by side instead of stacked. Happy with either CSS or HTML solutions, just not JavaScript. Apologies if my question isn't clear, I'm still learning!

I've attempted:

display: flex; align-items: center; justify-content: center;

But it's not quite working as expected.

Below is the CSS and HTML code snippet for your reference. Thank you to anyone who can offer assistance! I've kept the placeholders instead of actual images as this is for my photography website.

An example of what I've tried so far:

@charset "UTF-8";
button{
 display:inline-block;
 padding:0.5em 3em;
 border:0.16em solid #FFFFFF;
 margin:0 0.3em 0.3em 0;
 box-sizing: border-box;
 text-decoration:none;
 text-transform:uppercase;
 font-family:'Roboto',sans-serif;
 font-weight:400;
 color:#FFFFFF;
 text-align:center;
 transition: all 0.15s;  
}
button:hover{
 color:#DDDDDD;
 border-color:#DDDDDD;
}
button:active{
 color:#BBBBBB;
 border-color:#BBBBBB;
}
@media all and (max-width:30em){
 button{
  display:block;
  margin:0.4em auto;
 }
}

Answer №1

Within the HTML Code, there was a <br> tag positioned after every button, causing each button to be displayed on a new line. Resolution: Eliminate the unnecessary <br> tags following the button elements.

Answer №2

Wrap the buttons in a div container with CSS properties like display: flex; and flex-direction: row; to achieve the desired layout.

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

Align the text to the left on the same line as the content

I'm trying to align text and an image on the same line, but there's some empty space at the top of the text. Is there a way to align them? <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="styl ...

There seems to be an issue with d3js bar charts as they are not displaying on the screen and there

Recently, I started delving into the world of D3js and decided to try my hand at creating some bar charts. However, despite my efforts, the bar charts failed to display on the screen. <!DOCTYPE HTML> <html> <head> <title> My D3 Pra ...

Refresh DataTable while making a fetch request

Here is the HTML code snippet where I want to apply DataTable: <div id="reportrange" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <span></span> </div> <table id=" ...

There are additional elements that can be toggled, but I prefer to only toggle the one that I have selected

Every time I click on a table a, intending to toggle the .info inside the same div, it also toggles the .info in other divs. Can someone provide assistance with this issue? function info() { $('.table a').click(function() { $('.info ...

Python code to retrieve historical data in CSV format from a website that mandates authentication

Despite my thorough online search, I have been unable to uncover a solution to my dilemma. Specifically, I am interested in downloading daily csv files of historical data from a sunnyportal website that requires login. The login page can be found here: ht ...

Ways to modify the behavior and appearance of an HTML file input field

Looking to design a file upload field that shows an input type=text with the filename displayed, and a custom image in place of the usual upload button. Here's the concept: An uncomplicated solution without resorting to any workaround methods would ...

Is there a clash with another code causing issues in troubleshooting a straightforward jQuery function?

jQuery(document).ready(function() { jQuery("#bfCaptchaEntry").on("click", function(){ jQuery("#bfCaptchaEntry").css("background-color", "#FFFFFF"); }); jQuery("#bfCaptchaEntry").on("blur", function(){ jQuery("#b ...

How to dynamically add a form to your website

Looking to dynamically insert a form on a page based on the value selected from a datalist, all without having to reload the entire page. <form action='#' method='get'> <input list="category" name="category"> <da ...

What is the most efficient way to create a vertically stacked grid with minimal reliance on JavaScript?

When using an AngularJS ng-repeat, I encounter an issue with aligning elements on a new line. Instead of aligning the element above it, all elements on the same 'row' align with the lowest-hanging element. Even though I am using Bootstrap, I cou ...

Adjusting the height of the navigation bar in BootStrap

I'm having trouble resizing the height of the navbar-default in this Bootstrap sample. It seems to be too big for my needs. Are there any Bootstrap classes I can use to adjust the height? For example: <form class="navbar-form navbar-left" role="s ...

Simple method for swapping out an HTML string with image tags solely using JavaScript

In our Ionic 2 App, we are displaying content from a backend API in the form of Questions and Answers. The Answers are generated using summernote, allowing us to render raw HTML in the app. However, we need to replace all instances of img tags in the answe ...

What's the most efficient way to iterate through this Array and display its contents in HTML?

I'm struggling to sort a simple array and I think the issue might be related to the time format. I'm not sure how to reference it or how I can properly sort the time in this array format for future sorting. //function defined to input values ...

What is the method to identify the specific values causing a div to overflow in every direction?

Is there a method to accurately determine the specific quantities by which a div is overflowing in each direction? The information I found online only helped me calculate total horizontal or vertical overflow values. However, I am interested in knowing t ...

Utilize CSS to create spacing between columns in a webpage

I have incorporated a table into my project and here is the HTML snippet for reference: th { text-align: left; } td { height: 20px; font-size: 12px; background-color: #000; color: #fff; margin-right: 20px; border-top-left-radius: 10px; } ...

Passing a Javascript variable to the NAME attribute of an HTML <a href> tag: Steps to do it efficiently

I need assistance with passing a JavaScript variable to the NAME attribute of an HTML tag. Let's consider this script example: <script> var name = "Click here!"; </script> My goal is to pass the variable to some code in order for <a ...

Is there a faster alternative to using jQuery's indexOf method?

Looking to create a search box for a large set of options (around 2000 options) The indexOf method is very slow...any alternative solutions? Jquery Code : $('#textfortitlesearch').on('keyup', function() { var query = this.value ...

Move the textbox on the image by dragging it with the mouse

I need help figuring out how to move text on an image. I am currently designing an online custom shirt design website where users can add text to images. However, I am having trouble allowing users to adjust the position of the text on the image using th ...

How can the onclick attribute be modified in an HTML document?

I am looking to update the data-pro-bar-percent attribute of a progress bar from 80 to 100 when a specific link is clicked. The change in attribute needs to be as follows: data-pro-bar-percent="80" --> data-pro-bar-percent="100" This is the current HT ...

Disappearing elements with jQuery onClick event?

I'm currently diving into the world of jQuery and experimenting with adding functionality to one of my websites. I want to create a feature where clicking on a button will change the text and URL of a hyperlink. The problem I'm facing is that whe ...

jQuery - Enhancing User Experience with Dynamic Screen Updates

Is there a way to update the screen height when resizing or zooming the screen? Whenever I zoom the screen, the arrows break. I'm also curious if the method I'm using to display images on the screen is effective. It's supposed to be a paral ...