I was making a button, and it was completely fine and centered until i discovered a glitch where I could click anywhere on that line to go to index.html (the button was linking to index.html). My first idea was to change the display
attribute to inline opposed to block. Yet, the inline button won't center.
Code I had before:
.back {
color: black;
border-color: black;
background-color: white;
font-family: sans-serif;
border-style: solid;
border-width: 6px;
display: block;
font-size: 35px;
width: 30%;
margin-left: auto;
margin-right: auto;
text-align: center;
border-radius: 20px;
}
.back:hover {
transition-duration: .4s;
background-color: black;
color: white;
}
Code I have now:
.back {
color: black;
border-color: black;
background-color: white;
font-family: sans-serif;
border-style: solid;
border-width: 6px;
display: inline;
font-size: 35px;
width: 30%;
margin-left: auto;
margin-right: auto;
text-align: center;
border-radius: 20px;
}
.back:hover {
transition-duration: .4s;
background-color: black;
color: white;
}
See, it's exactly the same except for the inline.
Useful note: I did look up 'how to center a button' and I tried the w3schools way, but that just produced a big visual glitch.
Here's the HTML
HTML:
<a href="index.html"><button class="back">Back to homepage</button><a>
FIXED: left: 35%, position: absolute;