3

I have added border to the css button but for some reason, it is not taking effect.

Can someone please suggest a fix, Attaching the code in snippets

body {
  background: grey;
}

a.button {
  display: inline-block;
  -webkit-appearance: button;
  -moz-appearance: button;
  appearance: button;
  text-decoration: none;
  background-color: black;
  border: 1px solid white;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>CSS BUTTON</title>
</head>
<body>
<a href="#test" class="button">Click Me</a>
</body>
</html>
fubar
  • 16,918
  • 4
  • 37
  • 43
Badal Singh
  • 479
  • 8
  • 24

4 Answers4

5

Use -webkit-appearance: none; to turn off iOS default button styling, not "button". A great article here. And I've attached code for your button to work:

body {
background: blue;
}

a.button {
  display: inline-block;
  /*-webkit-appearance: button;
  -moz-appearance: button;
  appearance: button;*/
  -webkit-appearance: none;
  text-decoration: none;
  background-color: black;
  border: 1px solid white;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
}
<a href="#test" class="button">Click Me</a>
Nathaniel Flick
  • 2,902
  • 2
  • 22
  • 31
2

When you remove the property -webkit-appearance: button; or set to 'none' the button takes the effect. I think that appearance properties do not take border effects

a n
  • 72
  • 9
2

When using the -webkit-appearance property it's purpose is to provide the browser a way to display an element using platform-native styling based on the operating system's theme.

This leads to the operating system's styling interfering with your custom css. To apply custom styling you want to set -webkit-appearance to none in addition to your custom css.

Here's how you can use custom styling:

input {
    -webkit-appearance: none;
    -moz-appearance: none;
    -ms-appearance: none;
    appearance: none;
    display: inline-block;
    vertical-align: middle;
}

input[type="checkbox"] {
    border: 2px solid #555;
    width: 20px;
    height: 20px;
    outline: none;
    padding: 4px;
}
input[type="checkbox"]:checked {
    background: #555;
    background-clip: content-box;
}
input[type="radio"] {
    border: 2px solid #555;
    border-radius: 10px;
    width: 20px;
    height: 20px;
    outline: none;
    padding: 4px;
}
input[type="radio"]:checked {
    background: #555;
    background-clip: content-box;
}
p, h3 {
    color: #333;
    font-family: helvetica, arial;
}
label {
    display: inline-block;
    vertical-align: middle;
    margin: 0 0 -2px 8px;
}
<h3>Check:</h3>
<p><input type="checkbox"></input><label>Include Options</label></p>
<h3><br/>Select one:</h3>
<p><input type="radio" name="radio"></input><label>Option A</label></p>
<p><input type="radio" name="radio"></input><label>Option B</label></p>
David Ordaz
  • 241
  • 1
  • 2
  • 7
1

You are making button to -webkit-appearance-button so that makes border not visible.

a.button {
  display: inline-block;
  text-decoration: none;
  background-color: black;
  border: 5px solid red;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>CSS BUTTON</title>
</head>
<body>
<a href="#test" class="button">Click Me</a>
</body>
</html>
Amarjit Singh
  • 1,152
  • 7
  • 12