How to remove 'press button' effect and make button flat even on click
Asked Answered
B

8

24

I have the button with following styles

button {
  background: none;
  border-color: #87db41;
  color: #87db41;
  padding: 5px 5px;
  width: 30%;
  text-align: center;
  &: active {
    border-color: @aviata-color;

  }
}
<button>Subscribe</button>

And I want to remove 'press button' 3D effect. How can I do that? I am using bootstrap also on my site if it helps

Burkitt answered 17/7, 2015 at 9:9 Comment(3)
border-style: outset;Intoxicate
possible duplicate of Remove the complete styling of an HTML button/submitGuardi
You tag bootstrap... why don't you use "btn" classes from bootstrap... it's far more effective & customizable...Cheri
C
11

Just a suggestion.

When you use bootstrap, you can see, in the bootstrap.css code, this :

.btn {
  display: inline-block;
  padding: 6px 12px;
  margin-bottom: 0;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.42857143;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  -ms-touch-action: manipulation;
      touch-action: manipulation;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  background-image: none;
  border: 1px solid transparent;
  border-radius: 4px;
}
.btn:focus,
.btn:active:focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn.active.focus {
  outline: thin dotted;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}
.btn:hover,
.btn:focus,
.btn.focus {
  color: #333;
  text-decoration: none;
}
.btn:active,
.btn.active {
  background-image: none;
  outline: 0;
  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
}
.btn.disabled,
.btn[disabled],
fieldset[disabled] .btn {
  cursor: not-allowed;
  filter: alpha(opacity=65);
  -webkit-box-shadow: none;
          box-shadow: none;
  opacity: .65;
}
a.btn.disabled,
fieldset[disabled] a.btn {
  pointer-events: none;
}
.btn-default {
  color: #333;
  background-color: #fff;
  border-color: #ccc;
}
.btn-default:focus,
.btn-default.focus {
  color: #333;
  background-color: #e6e6e6;
  border-color: #8c8c8c;
}
.btn-default:hover {
  color: #333;
  background-color: #e6e6e6;
  border-color: #adadad;
}
.btn-default:active,
.btn-default.active,
.open > .dropdown-toggle.btn-default {
  color: #333;
  background-color: #e6e6e6;
  border-color: #adadad;
}
.btn-default:active:hover,
.btn-default.active:hover,
.open > .dropdown-toggle.btn-default:hover,
.btn-default:active:focus,
.btn-default.active:focus,
.open > .dropdown-toggle.btn-default:focus,
.btn-default:active.focus,
.btn-default.active.focus,
.open > .dropdown-toggle.btn-default.focus {
  color: #333;
  background-color: #d4d4d4;
  border-color: #8c8c8c;
}
.btn-default:active,
.btn-default.active,
.open > .dropdown-toggle.btn-default {
  background-image: none;
}
.btn-default.disabled,
.btn-default[disabled],
fieldset[disabled] .btn-default,
.btn-default.disabled:hover,
.btn-default[disabled]:hover,
fieldset[disabled] .btn-default:hover,
.btn-default.disabled:focus,
.btn-default[disabled]:focus,
fieldset[disabled] .btn-default:focus,
.btn-default.disabled.focus,
.btn-default[disabled].focus,
fieldset[disabled] .btn-default.focus,
.btn-default.disabled:active,
.btn-default[disabled]:active,
fieldset[disabled] .btn-default:active,
.btn-default.disabled.active,
.btn-default[disabled].active,
fieldset[disabled] .btn-default.active {
  background-color: #fff;
  border-color: #ccc;
}
.btn-default .badge {
  color: #fff;
  background-color: #333;
}
<button class="btn btn-default">BTN DEFAULT</button>

First part just defines the display properties for all "btn" classes items. The second part defines more specific display settings for "btn-default" items (there is also btn-success btn-warning and so on...).

If you want to customize this, just copy the code and change the name as a "btnCustom" and edit settings. OR just add some custom specific btn-* display, like btn-pink, or anything. I often use this to make several buttons color themes, in my projects sometimes I have things like btn-black, btn-purple,...

Below code as example of "btnCustom btnCustom-default", a button that will not move, just keep static with bootstrap "default" color theme :

.btnCustom {
  display: inline-block;
  padding: 6px 12px;
  margin-bottom: 0;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.42857143;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  background-image: none;
  border: 1px solid transparent;
  border-radius: 4px;
}
.btnCustom:hover,
.btnCustom:focus,
.btnCustom.focus {
  text-decoration: none;
}
.btnCustom:active,
.btnCustom.active {
  background-image: none;
}
.btnCustom.disabled,
.btnCustom[disabled],
fieldset[disabled] .btnCustom{
  cursor: not-allowed;
  filter: alpha(opacity=65);
  opacity: .65;
}
a.btnCustom.disabled,
fieldset[disabled] a.btnCustom{
  pointer-events: none;
}
.btnCustom-default {
  color: #333;
  background-color: #fff;
  border-color: #ccc;
}
.btnCustom-default:focus,
.btnCustom-default.focus {
  color: #333;
}
.btnCustom-default:hover {
  color: #333;
}
.btnCustom-default:active,
.btnCustom-default.active,
.open > .dropdown-toggle.btnCustom-default {
  color: #333;
}
.btnCustom-default:active:hover,
.btnCustom-default.active:hover,
.open > .dropdown-toggle.btnCustom-default:hover,
.btnCustom-default:active:focus,
.btnCustom-default.active:focus,
.open > .dropdown-toggle.btnCustom-default:focus,
.btnCustom-default:active.focus,
.btnCustom-default.active.focus,
.open > .dropdown-toggle.btnCustom-default.focus {
  color: #333;
}
.btnCustom-default:active,
.btnCustom-default.active,
.open > .dropdown-toggle.btnCustom-default {
  background-image: none;
}
.btnCustom-default.disabled,
.btnCustom-default[disabled],
fieldset[disabled] .btnCustom-default,
.btnCustom-default.disabled:hover,
.btnCustom-default[disabled]:hover,
fieldset[disabled] .btnCustom-default:hover,
.btnCustom-default.disabled:focus,
.btnCustom-default[disabled]:focus,
fieldset[disabled] .btnCustom-default:focus,
.btnCustom-default.disabled.focus,
.btnCustom-default[disabled].focus,
fieldset[disabled] .btnCustom-default.focus,
.btnCustom-default.disabled:active,
.btnCustom-default[disabled]:active,
fieldset[disabled] .btnCustom-default:active,
.btnCustom-default.disabled.active,
.btnCustom-default[disabled].active,
fieldset[disabled] .btnCustom-default.active {
}
.btnCustom-default .badge {
  color: #fff;
  background-color: #333;
}
<button class="btnCustom btnCustom-default">BTNCUSTOM DEFAULT</button>

This looks kinda complicated, or long. But this allows you to build your own css "bootstrap-like" classes style and it is then reusable easily, save your edits in a "customBootstrap.css" file and add it to your project.

Hope this helps ;)

Cheri answered 17/7, 2015 at 9:51 Comment(0)
I
13

Use the following CSS rule:

:active { border-style: outset;}

button {
  background: none;
  border-color: #87db41;
  color: #87db41;
  padding: 5px 5px;
  width: 30%;
  text-align: center;
  outline: none;
}
button:active {
  border-style: outset;
}
<button>Subscribe</button>

Also I remove outline from activated button.

Intoxicate answered 17/7, 2015 at 9:15 Comment(0)
C
11

Just a suggestion.

When you use bootstrap, you can see, in the bootstrap.css code, this :

.btn {
  display: inline-block;
  padding: 6px 12px;
  margin-bottom: 0;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.42857143;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  -ms-touch-action: manipulation;
      touch-action: manipulation;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  background-image: none;
  border: 1px solid transparent;
  border-radius: 4px;
}
.btn:focus,
.btn:active:focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn.active.focus {
  outline: thin dotted;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}
.btn:hover,
.btn:focus,
.btn.focus {
  color: #333;
  text-decoration: none;
}
.btn:active,
.btn.active {
  background-image: none;
  outline: 0;
  -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
          box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
}
.btn.disabled,
.btn[disabled],
fieldset[disabled] .btn {
  cursor: not-allowed;
  filter: alpha(opacity=65);
  -webkit-box-shadow: none;
          box-shadow: none;
  opacity: .65;
}
a.btn.disabled,
fieldset[disabled] a.btn {
  pointer-events: none;
}
.btn-default {
  color: #333;
  background-color: #fff;
  border-color: #ccc;
}
.btn-default:focus,
.btn-default.focus {
  color: #333;
  background-color: #e6e6e6;
  border-color: #8c8c8c;
}
.btn-default:hover {
  color: #333;
  background-color: #e6e6e6;
  border-color: #adadad;
}
.btn-default:active,
.btn-default.active,
.open > .dropdown-toggle.btn-default {
  color: #333;
  background-color: #e6e6e6;
  border-color: #adadad;
}
.btn-default:active:hover,
.btn-default.active:hover,
.open > .dropdown-toggle.btn-default:hover,
.btn-default:active:focus,
.btn-default.active:focus,
.open > .dropdown-toggle.btn-default:focus,
.btn-default:active.focus,
.btn-default.active.focus,
.open > .dropdown-toggle.btn-default.focus {
  color: #333;
  background-color: #d4d4d4;
  border-color: #8c8c8c;
}
.btn-default:active,
.btn-default.active,
.open > .dropdown-toggle.btn-default {
  background-image: none;
}
.btn-default.disabled,
.btn-default[disabled],
fieldset[disabled] .btn-default,
.btn-default.disabled:hover,
.btn-default[disabled]:hover,
fieldset[disabled] .btn-default:hover,
.btn-default.disabled:focus,
.btn-default[disabled]:focus,
fieldset[disabled] .btn-default:focus,
.btn-default.disabled.focus,
.btn-default[disabled].focus,
fieldset[disabled] .btn-default.focus,
.btn-default.disabled:active,
.btn-default[disabled]:active,
fieldset[disabled] .btn-default:active,
.btn-default.disabled.active,
.btn-default[disabled].active,
fieldset[disabled] .btn-default.active {
  background-color: #fff;
  border-color: #ccc;
}
.btn-default .badge {
  color: #fff;
  background-color: #333;
}
<button class="btn btn-default">BTN DEFAULT</button>

First part just defines the display properties for all "btn" classes items. The second part defines more specific display settings for "btn-default" items (there is also btn-success btn-warning and so on...).

If you want to customize this, just copy the code and change the name as a "btnCustom" and edit settings. OR just add some custom specific btn-* display, like btn-pink, or anything. I often use this to make several buttons color themes, in my projects sometimes I have things like btn-black, btn-purple,...

Below code as example of "btnCustom btnCustom-default", a button that will not move, just keep static with bootstrap "default" color theme :

.btnCustom {
  display: inline-block;
  padding: 6px 12px;
  margin-bottom: 0;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.42857143;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  background-image: none;
  border: 1px solid transparent;
  border-radius: 4px;
}
.btnCustom:hover,
.btnCustom:focus,
.btnCustom.focus {
  text-decoration: none;
}
.btnCustom:active,
.btnCustom.active {
  background-image: none;
}
.btnCustom.disabled,
.btnCustom[disabled],
fieldset[disabled] .btnCustom{
  cursor: not-allowed;
  filter: alpha(opacity=65);
  opacity: .65;
}
a.btnCustom.disabled,
fieldset[disabled] a.btnCustom{
  pointer-events: none;
}
.btnCustom-default {
  color: #333;
  background-color: #fff;
  border-color: #ccc;
}
.btnCustom-default:focus,
.btnCustom-default.focus {
  color: #333;
}
.btnCustom-default:hover {
  color: #333;
}
.btnCustom-default:active,
.btnCustom-default.active,
.open > .dropdown-toggle.btnCustom-default {
  color: #333;
}
.btnCustom-default:active:hover,
.btnCustom-default.active:hover,
.open > .dropdown-toggle.btnCustom-default:hover,
.btnCustom-default:active:focus,
.btnCustom-default.active:focus,
.open > .dropdown-toggle.btnCustom-default:focus,
.btnCustom-default:active.focus,
.btnCustom-default.active.focus,
.open > .dropdown-toggle.btnCustom-default.focus {
  color: #333;
}
.btnCustom-default:active,
.btnCustom-default.active,
.open > .dropdown-toggle.btnCustom-default {
  background-image: none;
}
.btnCustom-default.disabled,
.btnCustom-default[disabled],
fieldset[disabled] .btnCustom-default,
.btnCustom-default.disabled:hover,
.btnCustom-default[disabled]:hover,
fieldset[disabled] .btnCustom-default:hover,
.btnCustom-default.disabled:focus,
.btnCustom-default[disabled]:focus,
fieldset[disabled] .btnCustom-default:focus,
.btnCustom-default.disabled.focus,
.btnCustom-default[disabled].focus,
fieldset[disabled] .btnCustom-default.focus,
.btnCustom-default.disabled:active,
.btnCustom-default[disabled]:active,
fieldset[disabled] .btnCustom-default:active,
.btnCustom-default.disabled.active,
.btnCustom-default[disabled].active,
fieldset[disabled] .btnCustom-default.active {
}
.btnCustom-default .badge {
  color: #fff;
  background-color: #333;
}
<button class="btnCustom btnCustom-default">BTNCUSTOM DEFAULT</button>

This looks kinda complicated, or long. But this allows you to build your own css "bootstrap-like" classes style and it is then reusable easily, save your edits in a "customBootstrap.css" file and add it to your project.

Hope this helps ;)

Cheri answered 17/7, 2015 at 9:51 Comment(0)
K
8

Just set border-style to solid and include some active/focus states

button {
  background: none;
  border-style: solid;
  border-color: #87db41;
  color: #87db41;
  padding: 5px 5px;
  width: 30%;
  text-align: center;
  &: active {
    border-color: @aviata-color;

  }
}

button.active.focus, button.active:focus,
button.focus, button:active.focus, 
button:active:focus, button:focus {
  outline: none;
  box-shadow: none;
  background-color: white;
}
<button>Subscribe</button>
Krasnoyarsk answered 4/11, 2018 at 14:13 Comment(1)
box-shadow:none did the trick for me (some stylesheet that applied box-shadow:inset was causing a press button effect I couldn't get rid of). Thank you.Shipboard
E
2

By default button gets the property -webkit-appearance: button or any other depending on the browser.

You can reset that style in different ways.

Using border: none; or even border-style: outset; as it will turn the appearance into none.

Epiphenomenon answered 17/7, 2015 at 9:16 Comment(0)
K
2

if you are using bootstrap then please use bootstrap class btn, btn-primary then in your css put this code. I hope it will help you.

.btn {
    -webkit-border-radius: 0px;
    -moz-border-radius: 0px;
    -ms-border-radius: 0px;
    -o-border-radius: 0px;
    border-radius: 0px;
    outline: none;
    border: none;

}
.btn:active {
  border-style: outset;
  border: none;
}


<button class="btn btn-primary">Subscribe</button>
Kinetic answered 17/7, 2015 at 9:47 Comment(0)
S
0

You could add this CSS property:

button {outline: none !important;}

Sonics answered 22/4, 2019 at 14:58 Comment(0)
N
0
.btn:focus {
  outline: none;
  box-shadow: none;
}
Nanny answered 14/3, 2022 at 2:17 Comment(0)
D
0

if you are using bootstrap button then you need to follow below code to remove its default effect.

You could use this CSS:

button.<classname or id >{
    box-shadow:none !important;
    border-style:none;
}

for example : I want to remove the effect from my hamburger button so here i use same code like this .

<button class="navbar-light hamburger navbar-toggler collapsed" type="button" data-bs-toggle="collapse"


   button.hamburger{
        box-shadow:none !important;
        border-style:none;
    }
Doodle answered 22/5, 2023 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.