Adjacent buttons

I am trying to place two buttons side by side, but they keep appearing stacked on top of each other. Can anyone help me figure out how to solve this? Here's the code:

Styling (CSS):

<style type="text/css">

.button_example{
border:1px solid #B7B7B7; 
text-align: center; 
color: #FFFFFF; 
background-color: #D3D3D3;
}

.button_example:hover{
border:1px solid #B7B7B7; 
text-align: center; 
color: #1f1f1f; 
background-color: #ffffff;
}
</style></head>

Here is the HTML:

<div align="right"><a href="http://www.theamazingmonth.pusku.com/rules.html"><input type="button" class="button_example" value="Rules" /></a></div>
<div align="right"><a href="http://www.theamazingmonth.pusku.com/info.html"><input type="button" class="button_example" value="Info" /></a></div>

Any suggestions or solutions would be greatly appreciated!

Answer №1

Take a look at the jSFiDDLE

Remove the unnecessary div tag and wrap both anchor tags under a single div tag

Here's an example:

  <div align="right">
    <a href="http://www.theamazingmonth.pusku.com/rules.html"><input type="button" class="button_example" value="Rules" /></a>
    <a href="http://www.theamazingmonth.pusku.com/info.html"><input type="button" class="button_example" value="Info" /></a>
</div>

Answer №2

To address the issue, three key steps need to be taken:

  1. Replace the align="right" attribute with float:right.
  2. Erase the unnecessary <br> tag from within your code.
  3. Include a div styled with CSS clear:both once your buttons are in place.

View this jsfiddle for an example

Answer №3

Initially, there seems to be a bit of confusion in your HTML code:

<div><a><input/></div></a>
<div><a><input/></div></a>

The corrected structure should look like this:

<div><a><input/></a></div>
<div><a><input/></a></div>

Secondly, if you intend to create a clickable button, it may be more appropriate to use a <button> element instead of wrapping an <a><input></a>.

Lastly, consider adding the following style rules to your div elements:

float: right;

Remember to include a clear element after this to ensure proper layout, for example:

<br class="clearFloat">

And in your CSS file:

.clearFloat { clear: both; }

Answer №4

To simplify the code, remove two div elements and use only one div with the following CSS styling:

#butn{
    margin: 0 auto;
    display: block;
}
<div id="butn" align="right">
    <a href="http://www.theamazingmonth.pusku.com/rules.html"><input type="button" class="button_example" value="Rules" /></a>
    <a href="http://www.theamazingmonth.pusku.com/info.html"><input type="button" class="button_example" value="Info" /></a>
</div>

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

PHP's Encoding Woes Are Back in Action

I'm encountering encoding challenges on my website, and it's becoming quite frustrating. Allow me to elaborate My meta tag specifies utf8 as the charset. The scripts I'm using also have utf8 defined (<script type="text/javascript src=". ...

loading xml data into a table partially using jquery

Currently, I am utilizing AJAX to load and parse XML data. I have constructed a table where I am inserting the data from the XML using a loop. The issue lies in the fact that only around 3000 rows are being inserted into the table even though the XML conta ...

The CSS styling for changing the background-color and color of list items (li) is

Trying to customize the background-color and color of li, but despite inspecting it, the changes are not reflecting on the page. https://i.sstatic.net/P7GkK.png Does anyone know why this is happening and how to fix it? Update: Here's a link to the ...

adaptive height that scales with content proportionally

I am looking to achieve a responsive height based on the content inside my container. For example, I want the height of the container to adjust according to the text it contains. <!DOCTYPE html> <html lang="en"> <head> < ...

What is the best way to conceal the border and background color of the dropdown arrow in an HTML <select> tag?

Upon browsing the Mozilla homepage, I noticed a peculiar element in the center - a <select> option with an arrow lacking border and background color. In contrast, when visiting the Facebook sign-up page, the drop-down arrow adheres to the Windows sta ...

My Ruby on Rails app seems to be malfunctioning in a major way

Instead of sharing code snippets, I’ve encountered difficulties in getting my jQuery code to work correctly. If you're curious, you can view the issues on Stack Overflow: Why doesn’t this jQuery code work? and This jQuery hide function just does n ...

What could be causing my carousel slider images to not adapt to different screen sizes?

I recently added a carousel slider to my website, and while it looks great on larger screens like desktops and laptops, I noticed that the images are not scaling properly when viewed on smaller screen widths. This has resulted in non-responsiveness which i ...

The html input box's ability to handle overflow situations

Currently, I am working on creating a form that allows users to update data. <dl> <dt>Medical Needs:</dt> <dd class="med_needs" style="height:60px;overflow:auto"> <input type = "text" id="med_needs"name ="med_nee ...

The right column in Bootstrap is covering up the left column

Does anyone know why I am encountering an issue with my bootstrap navigation bar? When I try to have two columns in the navigation bar and resize the viewport, the right column overlaps the left one. This issue seems to be happening when the viewport size ...

What is the best way to construct the following layout with columns in Bootstrap?

My approach involved dividing the content into two equal columns using col-md-6. Each of these was further split into 3 columns using col-md-4. However, I faced an issue regarding achieving consistent spacing between columns on the right side. https://i.s ...

Switch between hiding and showing the DIV element flaw

I am currently working on a piece of code that involves simple HTML and JS to show/hide elements. Here is the code snippet: // Enabling forEach for 'querySelectorAll' and 'getElementsByClassName' HTMLCollection.prototype.forEach = No ...

Tips for customizing the border radius style of the menu in Vuetify's v-autocomplete component

I am looking to customize the appearance of the drop-down list in the v-autocomplete component by adding a border-radius style, as depicted in the image below. The current design I have achieved closely resembles the visual shown below. Previously, I app ...

Issue with the Textualizer effect in HTML not functioning properly

Having trouble with the textualizer effect - my screen is just blank. I've tried copying it from this source: . Inserted it into both visual studio and notepad, but still no success! <html> <head> <title></title> <script sr ...

Map region indicator tooltip

I possess a map that contains a specific area with a title. Here is the accompanying code: <map name="Map" id="Map"> <area alt="" shape="rect" coords="127,52,186,71" href="#" title="Extending telephone lines to other Egyptian governorates ...

Utilizing jQuery to retrieve multiple values from a select box through the onchange event

I have two select boxes with JavaScript on them. When I use filter1, my URL changes to www.url.com/&filter[]=6827 and it works perfectly. The selected option also works without any problems. However, I want a new select box like filter2 with multiple f ...

Button Click Does Not Trigger Bootstrap Modal Display

This is a sample Bootstrap document that includes JS and CSS files to display a list properly in Bootstrap. However, the Modal does not appear when clicking on Launch demo modal. No JavaScript errors are displayed in the Console. Can you help troubleshoot ...

Tips for implementing a sticky sidebar in HTML5 with jQuery

I currently have two files: index.php and aside.php. I've already created the contents of aside.php. Now, I want to make the aside page sticky. To achieve this, I referred to the following link: http://codepen.io/pouretrebelle/pen/yvcBz My struggle ...

The styles for the React calendar are not being properly applied to the calendar component due to CSS overriding

Having trouble overriding the default Calendar.css file in NextJS while creating a calendar component. Even after adding my own custom styles, they aren't being applied. Deleting the css file contents doesn't change the format either. Only when c ...

Mouse over the background of an image in jQuery to create a fade-in effect, without affecting any content inside

Currently facing a challenge with jquery. Please take a look at jsfiddle.net/7HXEF/1/. I am trying to create a DIV with a background image that fades in and out when the mouse hovers over it. However, the inner div with a link should not be affected by the ...

Saving HTML form field data through erb for persistent storage

Encountering an issue with erb while trying to populate the value of an HTML form field. The situation involves a scenario where the user has inputted an incorrect password and we want them to retain their name/email address information without having to r ...