Html 用于指针光标的 Bootstrap v4+ css 类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47269189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:58:40  来源:igfitidea点击:

Bootstrap v4+ css class for pointer cursor

htmlcsstwitter-bootstrapbootstrap-4

提问by w411 3

Is there any css class or attribute for pointer:cursorin bootstrap 4specially for button or link?

是否有任何CSS类或属性为pointer:cursor引导4专为按钮或链接?

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-success">Sample Button</button>

采纳答案by Klooven

UPDATE for Bootstrap 4 stable

Bootstrap 4 稳定版的更新

The cursor: pointer;rule has been restored, so buttons will now by default have the cursor on hover:

cursor: pointer;规则已经恢复,所以按钮将现在默认有悬停光标:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<button type="button" class="btn btn-success">Sample Button</button>



No, there isn't. You need to make some custom CSS for this.

不,没有。您需要为此制作一些自定义 CSS。

If you just need a link that looks like a button (with pointer), use this:

如果您只需要一个看起来像按钮(带指针)的链接,请使用:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<a class="btn btn-success" href="#" role="button">Sample Button</a>

回答by Hari Das

Unfortunately there is no such class in Bootstrap as of now (27th Jan 2019).

不幸的是,截至目前(2019 年 1 月 27 日),Bootstrap 中没有这样的类。

I scanned through bootstrap code and discovered following classes that use cursor: pointer. Seems like it is not a good idea to use any of them specifically for cursor: pointer.

我扫描了引导程序代码并发现了以下使用cursor 的: pointer。似乎将它们中的任何一个专门用于 cursor:pointer 似乎都不是一个好主意。

summary {
  display: list-item;
  cursor: pointer;
}
.btn:not(:disabled):not(.disabled) {
  cursor: pointer;
}
.custom-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 0.5rem;
  color: transparent;
  cursor: pointer;
  background-color: #dee2e6;
  border-color: transparent;
  border-radius: 1rem;
}
.custom-range::-moz-range-track {
  width: 100%;
  height: 0.5rem;
  color: transparent;
  cursor: pointer;
  background-color: #dee2e6;
  border-color: transparent;
  border-radius: 1rem;
}
.custom-range::-ms-track {
  width: 100%;
  height: 0.5rem;
  color: transparent;
  cursor: pointer;
  background-color: transparent;
  border-color: transparent;
  border-width: 0.5rem;
}
.navbar-toggler:not(:disabled):not(.disabled) {
  cursor: pointer;
}
.page-link:not(:disabled):not(.disabled) {
  cursor: pointer;
}
.close:not(:disabled):not(.disabled) {
  cursor: pointer;
}
.carousel-indicators li {
  box-sizing: content-box;
  -ms-flex: 0 1 auto;
  flex: 0 1 auto;
  width: 30px;
  height: 3px;
  margin-right: 3px;
  margin-left: 3px;
  text-indent: -999px;
  cursor: pointer;
  background-color: #fff;
  background-clip: padding-box;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  opacity: .5;
  transition: opacity 0.6s ease;
}

The only OBVIOUS SOLUTION:

唯一明显的解决方案:

What I would suggest you is just to create a class in your common css as cursor-pointer. That is simple and elegant as of now.

我建议你只是在你的常用 css 中创建一个类作为cursor-pointer. 到目前为止,这是简单而优雅的。

.cursor-pointer{
  cursor: pointer;
}
<div class="cursor-pointer">Hover on  me</div>

回答by Alexis Paques

I usually just add the following custom CSS, the W3School exampleprepended with cursor-

我通常只添加以下自定义 CSS,W3School 示例cursor-

.cursor-alias {cursor: alias;}
.cursor-all-scroll {cursor: all-scroll;}
.cursor-auto {cursor: auto;}
.cursor-cell {cursor: cell;}
.cursor-context-menu {cursor: context-menu;}
.cursor-col-resize {cursor: col-resize;}
.cursor-copy {cursor: copy;}
.cursor-crosshair {cursor: crosshair;}
.cursor-default {cursor: default;}
.cursor-e-resize {cursor: e-resize;}
.cursor-ew-resize {cursor: ew-resize;}
.cursor-grab {cursor: -webkit-grab; cursor: grab;}
.cursor-grabbing {cursor: -webkit-grabbing; cursor: grabbing;}
.cursor-help {cursor: help;}
.cursor-move {cursor: move;}
.cursor-n-resize {cursor: n-resize;}
.cursor-ne-resize {cursor: ne-resize;}
.cursor-nesw-resize {cursor: nesw-resize;}
.cursor-ns-resize {cursor: ns-resize;}
.cursor-nw-resize {cursor: nw-resize;}
.cursor-nwse-resize {cursor: nwse-resize;}
.cursor-no-drop {cursor: no-drop;}
.cursor-none {cursor: none;}
.cursor-not-allowed {cursor: not-allowed;}
.cursor-pointer {cursor: pointer;}
.cursor-progress {cursor: progress;}
.cursor-row-resize {cursor: row-resize;}
.cursor-s-resize {cursor: s-resize;}
.cursor-se-resize {cursor: se-resize;}
.cursor-sw-resize {cursor: sw-resize;}
.cursor-text {cursor: text;}
.cursor-w-resize {cursor: w-resize;}
.cursor-wait {cursor: wait;}
.cursor-zoom-in {cursor: zoom-in;}
.cursor-zoom-out {cursor: zoom-out;}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-success cursor-pointer">Sample Button</button>

回答by Stnfordly

Bootstrap 3 - Just adding the "btn" Class worked for me.

Bootstrap 3 - 只需添加“ btn”类对我有用

Withoutpointer cursor:

没有指针光标:

<span class="label label-success">text</span>

Withpointer cursor:

使用指针光标:

<span class="label label-success btn">text</span>

回答by Coder Amogh

I tried and found out that if you add a class called btnyou can get that handor cursoricon if you hover over the mouse to that element. Try and see.

我尝试并发现如果您添加一个名为的类,如果您将鼠标悬停在该元素上,btn您可以获得该类handcursor图标。试试看。

Example:

例子:

<span class="btn">Hovering over must have mouse cursor set to hand or pointer!</span>

Cheers!

干杯!