My HTML5 design features buttons that overlap each other

When I zoom in, I notice two buttons - one on the left and one on the right. The larger button behind the main one changes color when hovered over but does not direct me to where I want to go. It seems like it's related to the width setting of 180px with auto height. I want this mysterious appearing button to disappear.

HTML

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="setupstylesheet.css">
        <title>Setting up Your Website Folders</title>
    </head>
    <body>
        <div id="body">
            <img src="Images/web-development-banner.jpg" width="100%" height="400">
            <h1 class="webheading">Website Developement</h1>
            <div class="margin">
                <div class="shading">
                    <h1>2. Setting Up Your Website Folders</h1>
                    <p>In order to have a website, you need to have it set our in a specific way, but make it easy to navigate. This is how you set up your website folders and files:</p>
                    <ol>
                        <li> Create a folder on your hard drive or a USB called "Website".</li>
                        <li>Open a blank Notepad++ document.</li>
                        <li>Save the blank document in your "Website" folder with the name "Index", and a file extension of ".html".</li>
                        <li>Open another blank Notepad++ document and call it "StyleSheet" with the file extension of ".css". Save it in your "Website: folder as well.</li>
                        <li>Inside your "Website" folder, create another folder called "Images".</li>
                        <li>If you wish to include music on your website, create another folder in your "Website" folder called "Audio".</li>
                    </ol>
                    <p>Your website folder should now look something like this:</p>
                    <img src="Images/webfolderdemo.jpg" width="80%" height="80%">
                    <p>Remember whenever you add pictures, put them in the "Images" folder, and music or other audio, put in the "Audio" folder."
                    <div class="needs">
                        <a href="index.html">
                            <button type="button" class="needs">1. Things you need</button>
                        </a>
                    </div>
                    <div class="extrainfo">
                        <a href="extrainfo.html">
                            <button type="button" class="extrainfo">3. Extra Information</button>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

CSS

#body {
    background: url(Images/bigimage.jpg);
    background-color:#000000;
    background-size: 100% 100%;
    width: auto;
    height: auto;
    background-repeat: no-repeat;
    background-attachment: fixed;
    margin: 0px;
    margin-top: 0px;
    color: #FFFFFF;
}

.webheading {
    size: 300px;
    text-align: center;
    color: #FFFF00;
    font-family: "Arial Black", Gadget, sans-serif;
}

.needs {
    display: inline-block;
    font-weight: bold;
    font-family: "Arial Black", Gadget, sans-serif;
    border: 2px solid #FFFF00;
    background-color: #00FF00;
    border-radius: 10px;
    height: auto;
    width: 180px;
}

.needs:hover {
    background-color: #4CAF50;
    color: white;
}

.extrainfo {
    float: right;
    display: inline-block;
    font-weight: bold;
    font-family: "Arial Black", Gadget, sans-serif;
    border: 2px solid #FFFF00;
    background-color: #00FF00;
    border-radius: 10px;
    height: auto;
    width: 180px;
}

.extrainfo:hover {
    background-color: #4CAF50;
    color: white;
}

.margin {
    margin-left: 20px;
    margin-right: 20px;
 }

.shading {
    border-radius: 15px;
    width: auto;
    height: auto;
    padding: 10px 25px;
    text-align: left;
    background-color:rgba(0, 0, 0, 0.6)
}

Answer №1

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="setupstylesheet.css">
        <title>How to Organize Your Website Folders</title>
    </head>
    <body>
        <div id="body">
            <img src="Images/web-development-banner.jpg" width="100%" height="400">
            <h1 class="webheading">Website Development</h1>
            <div class="margin">
                <div class="shading">
                    <h1>2. Setting Up Your Website Folders</h1>
                    <p>To create a functional website structure, follow these steps for organizing your folders and files:</p>
                    <ol>
                        <li> Create a folder named "Website" on your hard drive or USB.</li>
                        <li>Open a new document in Notepad++.</li>
                        <li>Save the document as "Index.html" in the "Website" folder.</li>
                        <li>Create another document named "StyleSheet.css" and save it in the "Website" folder.</li>
                        <li>Within the "Website" folder, create a subfolder called "Images".</li>
                        <li>For including music, create a folder named "Audio" inside the "Website" folder.</li>
                    </ol>
                    <p>Your website directory should now resemble this setup:</p>
                    <img src="Images/webfolderdemo.jpg" width="80%" height="80%">
                    <p>Remember to place images in the "Images" folder and audio files in the "Audio" folder."</p>
                    <div class="button-wrap">
                        <a href="index.html">
                            <button type="button" class="needs">1. Necessary Tools</button>
                        </a>
                    </div>
                    <div class="button-wrap">
                        <a href="extrainfo.html">
                            <button type="button" class="extrainfo">3. Additional Info</button>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

css -->

.button-wrap {
    display: inline-block;
    width: 171px;
}

Remove float:right from .extrainfo Remove width styling for both buttons.

Answer №2

To simplify your HTML code, you can use the following structure:

<div class="container">
  <a href="index.html" class="button needs">
    1. Essentials
  </a>
  <a href="extrainfo.html" class="button extrainfo">
    3. Additional Details
  </a>
</div>

For styling with CSS, consider this example:

.container {
  text-align: center;
}

.button_test {
  display: inline-block;
  font-weight: bold;
  font-family: "Arial Black", Gadget, sans-serif;
  border: 2px solid #FFFF00;
  background-color: #00FF00;
  border-radius: 10px;
  height: auto;
  width: 180px;
}

.button_test.extrainfo {
  /* Add specific styles for .extrainfo here */
}

Answer №3

The issue with your buttons overlapping is likely due to them being in a 'floating' state. To resolve this, make sure that the button and container do not have the same class, as noted in the previous comments.

Fix the class situation for your button/div, and then apply clear: both; on the containers or adjust the display properties using display: block; or display: inline-block;. This should prevent the buttons from overlapping.

Answer №4

Simply adjust the "float" property within the button's styling class to prevent any further overlapping issues.

In instances where you wish to retain the "float" setting, consider incorporating the "padding" attribute into your button elements.

Answer №5

Problem solved!

I made the mistake of using the same class name for both my divs and buttons, which caused duplication. However, I discovered a simpler way to align my buttons on a single row without wrapping each in a div:

Here's the revised HTML code:

<div>
    <a href="index.html">
        <button type="button" class="needs">1. Things you need</button>
    </a>
    <a href="extrainfo.html">
        <button type="button" class="extrainfo">3. Extra Information</button>
    </a>
</div>

No changes were necessary in the CSS styling:

.needs {
    display: inline-block;
    font-weight: bold;
    font-family: "Arial Black", Gadget, sans-serif;
    border: 2px solid #FFFF00;
    background-color: #00FF00;
    border-radius: 10px;
    height: auto;
    width: 180px;
}

.needs:hover {
    background-color: #4CAF50;
    color: white;
}

.extrainfo {
    float: right;
    display: inline-block;
    font-weight: bold;
    font-family: "Arial Black", Gadget, sans-serif;
    border: 2px solid #FFFF00;
    background-color: #00FF00;
    border-radius: 10px;
    height: auto;
    width: 180px;
}

.extrainfo:hover {
    background-color: #4CAF50;
    color: white;
}

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

What is the secret to creating letters to look just like they do in this wireframe?

Currently, I am referencing a wireframe for my project design. You can view it here: In the top banner of the wireframe, there are two sections labeled "find a hike" and "plan a hike." I am unsure how to recreate the style of letters used in the banner - ...

Custom CSS styles for purchasing stocks using percentages

Can someone assist me in fixing the CSS for this custom card within a modal box? <!--Card--> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <input type="text" id="market-searc ...

Navigation bar expansion issue in Boostrap needs fixing

Hello, currently I am in the process of creating my portfolio website. This is my first time working with bootstrap so I am still figuring things out. Right now, I am trying to create a navbar that expands using navbar-expand, but for some reason it's ...

Canceling out the overlay opacity of divs

Is there a way to ensure that when overlaying two divs with semi-transparent backgrounds, the opacity of each div does not add to one another? In simple terms, I want to maintain consistent color between the two divs even when they overlap. I have created ...

Calculation for determining the fill of a DIV's remaining height

Here is what I have: <div id="modal-container"> <div id="modal-body"></div> <div id="modal-footer"></div> </div> I am currently working on a JavaScript function to adjust the height of #modal-body to fill in the re ...

Choosing multiple buttons

What is the best method for allowing users to select an entire button (not a radio button or checkbox) so that it changes color once selected? The goal is to enable users to select multiple buttons and then submit them together. ...

What is the best way to add a gradient color to the bottom of your content?

Seeking assistance in replicating the unique UI design featured in the image below, taken from a course description section on udemy.com. The goal is to create a gradient effect on specific parts of the content, similar to what is shown in the image. http ...

Modifying the design of a webpage using JavaScript, proceeding to the next step, and then navigating back

I am currently working on enhancing the user experience by providing customers with the option to either log in to our booking system or fill out a form with their information. When they first arrive on the page, they are presented with these two choices. ...

Steps for dynamically applying a CSS class to items within an ASP.NET CheckBoxlist in an HTML table

Is there a way to dynamically apply CSS classes to ASP.NET CheckBoxlist HTML table elements programmatically? For instance, I would like the "table", "tr", and "td" tags in the output below (as seen in the browser View Source) to include CSS styles. < ...

I am having trouble getting my JavaScript to load

I've hit a roadblock trying to understand why my JavaScript code isn't executing properly. Could someone kindly point out what I may have overlooked? :( JSFiddle Link HTML Snippet <div class="po-markup"> <br> <a href="# ...

Utilize jQuery to encase the final word of a paragraph within span tags

Greetings! Consider the following HTML snippet: <p>Phasellus sit amet auctor velit, ac egestas augue.</p> I am interested in enclosing the last word within span tags to achieve the following result: <p>Phasellus sit amet auctor velit, ...

Elevating the Sidebar: Transforming Bootstrap 4 Sidebar into a Top

Recently, I delved into the topic of creating a responsive sidebar menu in Bootstrap 4. After exploring various solutions, I opted for an alternate version. Here's the HTML code snippet that I implemented: <div class="container-fluid"> < ...

Changing $scope does not automatically refresh the selected option when using ng-options with <select> in AngularJS

My select element is structured like this: <select ng-model="exportParam" ng-options="item as item.lib for item in allExportParams | orderBy:'lib'" class="form-control"> </select> To save its state for later display, I sto ...

Obtaining localStream for muting microphone during SIP.js call reception

My approach to muting the microphone involves using a mediastream obtained through the sessionDescriptionHandler's userMedia event. session.sessionDescriptionHandler.on('userMedia', onUserMediaObtained.bind(this)) function onUserMediaObta ...

Sending the most recent result to each dynamically created div

In my WordPress project, I have an event panel that displays upcoming event details and shows the remaining time until the next event. The countdown dynamically gets values from the database and calculates the time left based on the user's input in th ...

Show Navbar Toggler only when in Portrait mode on mobile devices, not Landscape mode

Attempting to create a responsive website utilizing Bootstrap 4, I encountered a problem with the menu expanding in Landscape orientation on mobile devices, causing distortion. How can I ensure the menu stays collapsed in Landscape orientation? Despite ha ...

Angular2's customer filter pipe allows for easy sorting and filtering of

Check out the component view below: <h2>Topic listing</h2> <form id="filter"> <label>Filter topics by name:</label> <input type="text" [(ngModel)]="term"> </form> <ul id="topic-listing"> <li *ngFo ...

What is the best way to display fewer pages in Pagination on a mobile view?

Issue We need to display fewer pages in the mobile view so that it can align with the heading (My Orders) on the same line. https://i.sstatic.net/JROvk.png Resource material-ui/pagination Current Progress I have successfully removed the Next and Prev ...

`Loading CSS files in Node.js with Express``

My CSS isn't loading properly when I run my HTML file. Even though the HTML is correctly linked to the CSS, it seems like express and node.js are not recognizing it. I find it confusing to understand the articles, tutorials, and stack overflow questio ...

The secret item concealed beneath the Map [React]

Currently, I am facing an issue with google-map-react where the dropMenu element is being hidden under the map in my application. Does anyone have any suggestions on how to resolve this? Screenshots: https://i.sstatic.net/Z3Zp7.png https://i.sstatic.net/J ...