What is the best way to align a button to the bottom right corner using CSS?

After successfully positioning the buttons to the bottom left, I encountered an issue where one of the buttons disappeared when navigating back to the page. The missing button only appears after scrolling down. Can someone please assist with this problem?

HTML

<!Doctype html>
<html>
  <head>
  <title>Forsaken </title>
  <link href="main.css" rel="stlesheet" type="text/css">
  </head>

   <body>


  <a href="teams.html"><button><img class="#topleft" src="icon1.jpg  " width="100%" alt="Teams" ></button></a>
  <a href="store.html"><button><img class="#topright" src="icon2.jpg  " width="100%" alt="store" ></button></a>
  <a href="sponsors.html"><button><img class="#bottomleft" src="icon4.jpg  " width="100%" alt="sponsors" ></button></a>
  <a href="aboutus.html"><button><img class="#bottomright" src="icon3.jpg  " width="100%" alt="aboutus" ></button></a>


</body>


</html>

CSS

#topleft {
    position: fixed;
    top: 0px; 
    left: 0px;
}

#topright {
    position: fixed;
    top: 0px;
    right: 0px;
}

#left {
    position: fixed;
    left: 0px;
}

#right {
    position: fixed;
    right: 0px;
}


div {
    border-style:solid;
    border-width:0px;   
    border-color:#000000;
}

#yes {
  border: none;
    padding: 0;
    background: none;
}

.flat {
    border: none;
    background: #222;
    color: #FFF;
    padding: 0px 0px;
    font-size: 22px;
    font-family: Palatino;
    font-weight: bold;
}

.lighter {
    background: #666;
}

#no {
  border: none;
    padding: 0;
    background: none;
}

.flat {
    border: none;
    background: #222;
    color: #FFF;
    padding: 0px 0px;
    font-size: 22px;
    font-family: Palatino;
    font-weight: bold;
}

.lighter {
    background: #666;
}

p.s All buttons are functional except for the About Us button that is not displaying correctly.

Answer №1

Give this a try:

.topLeft{
  position: absolute;
  top:0;
  left:0;
}
.topRight{
  position: absolute;
  top:0;
  right: 0;
}
.bottomLeft{
  position: absolute;
  bottom: 0;
  left: 0;
}
.bottomRight{
  position: absolute;
  bottom: 0;
  right:0;
}
<button class="topLeft"><a href="#">Click Me</a></button>
<button class="topRight"><a href="#">Click Me</a></button>
<button class="bottomLeft"><a href="#">Click Me</a></button>
<button class="bottomRight"><a href="#">Click Me</a></button>

Here is the working CodePen example.

Please Note

Avoid using hashtags within a class declaration as it's considered bad practice (hashtags are meant for catching IDs).

Your code may not have worked because of this issue.

Feel free to reach out if you encounter any problems.

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

hover over the picture with your cursor

Struggling with jquery and css, could use some assistance :) Check out my html code below: <html> <head> //myscripts <script> $(document).ready(function(){ $(".cover").hover(function(){ //the function i need to write } ...

How can I arrange the "elements" within a bootstrap container?

Check out the code display here: Here's what I aim for it to show The alignment of the elements has been a real challenge for me. I just can't seem to get the "Gender:", "Gender RadioButton list", "Age:", "Age RadioButton list" to appear in 4 c ...

unable to simultaneously scroll two elements

Within the realm of reactjs, I've crafted a function that smoothly scrolls elements by utilizing a useRef: ref.current?.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "center", }); ...

Adding fewer components to your current Angular 5 project

I have a JS Fiddle showcasing a CSS chart. How can I integrate LESS into my current Angular 5 project to make use of this chart? Also, where should I place the JavaScript and references to the LESS file from this example within my Angular component? The li ...

Starting up with card and a loop counter

Can anyone help me with getting my card bootstrapping implemented in my .html to be centered? Here is the code I'm working with: <h1> 10 Games Recommended Based on {{ selected }} </h1> <div class="container"> ...

Steps to remove a scrollbar from a fullscreen slider

Can anyone provide code examples on how to disable the scroll bar on a full screen slider? I want to have a scroll down button on each slider that, when clicked, will show the scrollbar only below the slider. I don't want the scrollbar to be visible ...

Implementation of the Bootstrap navbar hamburger menu is malfunctioning within a Django application

I recently completed a django app, but I'm facing an unusual issue with the bootstrap navbar not displaying menu items on mobile devices. When I access my app from a mobile browser, the hamburger menu fails to expand and show the navigation items. It ...

When I hover over it, my play button refuses to show up

I am in the process of creating a music streaming website and I would like the play button to appear when hovering over a song. However, I am encountering an issue with the CSS section overriding the others that are meant for different parts (I am using Fo ...

Disable the click functionality while preserving the hover feature

Due to my previous question being incorrectly marked as a duplicate, even though it wasn't, and no one is rectifying the mistake, I am re-posting my inquiry. I am dealing with an <a> element that has a default onClick function. This <a> a ...

Full-width Dropdown Menu within a Container with a Maximum Width

Is it possible to make a dropdown menu within a navigation bar open to the full width of the page, even when the parent container has a maximum width of 500px? My attempt to use 100vw resulted in misaligned dropdown elements, and I cannot move the navbar ...

Texture overlay on a Bulma video background

Is there a way to create an overlay on a background video without covering other components? I want the components to remain visible and on top of everything else, with the background video in the far background, followed by the texture layer, and everyth ...

Text hidden within the image, each line concealing a separate message

I am having an issue where my image is overlaying the text. I would like the text to wrap around the image and for any hidden text to appear on a different line. How can this be achieved? Here is the CSS code I am using: div.relative { position: relati ...

Steps for including an animation class in a div

Is it possible to add the sweep to top blue color animation to the red box using a set-timeout function instead of hover? I tried using the following code but it doesn't seem to be working. Can you help me troubleshoot? setTimeout(function() { $( ...

Using the Flex display property automatically adjusts the height of a button based on its

I have a main container, and within it, an <h1> heading and a <button>. I align them using justify content-between. Since the main container has a d-flex class, the button ends up having the same height as the main container. Is there a way to ...

What is the best way to align text within both the grid row and column while still maintaining the border?

When I apply justify-self and align-self rules, it successfully centers items vertically and horizontally. However, the issue arises when the borders wrap around the text instead of expanding all the way to the edges. My goal is to have a 1px border aroun ...

I'm having trouble getting the burger menu to look and function the way I want in Bootstrap using CSS and HTML

Currently involved in a school project focusing on creating responsive web design. We have achieved almost all of our group's objectives, but I am facing one last hurdle that I am hoping the wonderful community at Stack Overflow can assist me with. I ...

Ensuring consistent height for the initial div across separate columns (Bootstrap 4)

Here is the HTML structure that needs adjustment: <div class="container"> <div class="row"> <div class="col-12 col-sm-12 col-lg-4 col-md-4"> <div class="title">Some title</div> <ul&g ...

The clash of names between tags and classes in Tumblr themes can cause conflicts

I have discovered a method to customize the style of different posts based on their respective "#tags" using {TagsAsClasses}: <div class="post {TagsAsClasses}"> div.tag { /* customize styling here */ } While this approach works well, I encount ...

The value of the HTML input control vanishes once padding is added

I am in need of some assistance with CSS in formatting the text box for BID VALUE (input element) (See in Image 1) Image 1 https://i.sstatic.net/4fQk8.jpg The product link can be found here When I try to widen the text box using padding, the text value in ...

The overflow hidden property does not seem to be effective when used in conjunction with parallax

The issue arises when I attempt to use the overflow hidden property in combination with parallax scrolling. Although everything seems to be working correctly with JavaScript for parallax scrolling, setting the overflow to hidden does not contain the image ...