如何删除 'press button' 效果并使按钮即使在单击时也变平
How to remove 'press button' effect and make button flat even on click
我有以下样式的按钮
button {
background: none;
border-color: #87db41;
color: #87db41;
padding: 5px 5px;
width: 30%;
text-align: center;
&: active {
border-color: @aviata-color;
}
}
<button>Subscribe</button>
我想删除 'press button' 3D 效果。我怎样才能做到这一点?
如果有帮助,我也在我的网站上使用 bootstrap
使用以下 CSS 规则:
: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>
我还删除了激活按钮的轮廓。
默认情况下 button
获取 属性 -webkit-appearance: button
或任何其他取决于浏览器。
您可以用不同的方式重置该样式。
使用 border: none;
甚至 border-style: outset;
,因为它会将 appearance
变成 none
。
如果您正在使用 bootstrap 那么请使用 bootstrap class btn, btn-primary 然后在您的 css 中输入此代码。希望对你有所帮助。
.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>
只是一个建议。
当您使用 bootstrap 时,您可以在 bootstrap.css 代码中看到:
.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>
第一部分只是定义所有 "btn" 类 项的显示属性。
第二部分为"btn-default"项定义了更具体的显示设置(还有btn-success btn-warning等等...)。
如果你想自定义它,只需复制代码并将名称更改为 "btnCustom" 并编辑设置。或者只是添加一些自定义特定的 btn-* 显示,如 btn-pink 或任何东西。我经常用它来制作几个按钮颜色主题,在我的项目中有时我有 btn-black,btn-purple,...
下面的代码作为"btnCustom btnCustom-default"的例子,一个按钮不会移动,只是保持静止bootstrap "default" 颜色主题:
.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>
这看起来有点复杂,或者说很长。
但这允许您构建自己的 css "bootstrap-like" 类 样式,然后可以轻松地重复使用它,将您的编辑保存在 "customBootstrap.css" 文件中并将其添加到您的项目中。
希望对您有所帮助 ;)
只需将 border-style
设置为 solid
并包含一些 active/focus
状态
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>
您可以添加这个 CSS 属性:
button {outline: none !important;}
.btn:focus {
outline: none;
box-shadow: none;
}
我有以下样式的按钮
button {
background: none;
border-color: #87db41;
color: #87db41;
padding: 5px 5px;
width: 30%;
text-align: center;
&: active {
border-color: @aviata-color;
}
}
<button>Subscribe</button>
我想删除 'press button' 3D 效果。我怎样才能做到这一点? 如果有帮助,我也在我的网站上使用 bootstrap
使用以下 CSS 规则:
: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>
我还删除了激活按钮的轮廓。
默认情况下 button
获取 属性 -webkit-appearance: button
或任何其他取决于浏览器。
您可以用不同的方式重置该样式。
使用 border: none;
甚至 border-style: outset;
,因为它会将 appearance
变成 none
。
如果您正在使用 bootstrap 那么请使用 bootstrap class btn, btn-primary 然后在您的 css 中输入此代码。希望对你有所帮助。
.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>
只是一个建议。
当您使用 bootstrap 时,您可以在 bootstrap.css 代码中看到:
.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>
第一部分只是定义所有 "btn" 类 项的显示属性。 第二部分为"btn-default"项定义了更具体的显示设置(还有btn-success btn-warning等等...)。
如果你想自定义它,只需复制代码并将名称更改为 "btnCustom" 并编辑设置。或者只是添加一些自定义特定的 btn-* 显示,如 btn-pink 或任何东西。我经常用它来制作几个按钮颜色主题,在我的项目中有时我有 btn-black,btn-purple,...
下面的代码作为"btnCustom btnCustom-default"的例子,一个按钮不会移动,只是保持静止bootstrap "default" 颜色主题:
.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>
这看起来有点复杂,或者说很长。 但这允许您构建自己的 css "bootstrap-like" 类 样式,然后可以轻松地重复使用它,将您的编辑保存在 "customBootstrap.css" 文件中并将其添加到您的项目中。
希望对您有所帮助 ;)
只需将 border-style
设置为 solid
并包含一些 active/focus
状态
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>
您可以添加这个 CSS 属性:
button {outline: none !important;}
.btn:focus {
outline: none;
box-shadow: none;
}