我有此按钮图像:
我想知道是否有可能使<a href="">some words</a>
链接的样式简单并显示为该按钮?
如果有可能,我该怎么做?
cursor: pointer;
css,以使光标看起来像是用食指指向的手,因为这也与常规按钮一起发生,并且对用户有用。
我有此按钮图像:
我想知道是否有可能使<a href="">some words</a>
链接的样式简单并显示为该按钮?
如果有可能,我该怎么做?
cursor: pointer;
css,以使光标看起来像是用食指指向的手,因为这也与常规按钮一起发生,并且对用户有用。
Answers:
使用CSS:
.button {
display: block;
width: 115px;
height: 25px;
background: #4E9CAF;
padding: 10px;
text-align: center;
border-radius: 5px;
color: white;
font-weight: bold;
line-height: 25px;
}
<a class="button">Add Problem</a>
a
直接应用于标记(a {display: block ...}
)时,这才对我有用,这是不可接受的。您知道为什么class
标记内的属性a
不起作用吗?:(我使用的是Firefox27。我也尝试过a.button {...}
,它也不起作用
text-decoration:none
检查Bootstrap的docs。.btn
存在一个类,并且该类可与a
标记一起使用,但是您需要在.btn-*
该类中添加特定的.btn
类。
例如: <a class="btn btn-info"></a>
您可以轻松地将带有链接的按钮包装成这样 <a href="#"> <button>my button </button> </a>
这样的事情类似于一个按钮:
a.LinkButton {
border-style: solid;
border-width : 1px 1px 1px 1px;
text-decoration : none;
padding : 4px;
border-color : #000000
}
有关示例,请参见http://jsfiddle.net/r7v5c/1/。
试试这个:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<h2>Button Tags</h2>
<a href="#" class="btn btn-info" role="button">Link Button</a>
<button type="button" class="btn btn-info">Button</button>
<input type="button" class="btn btn-info" value="Input Button">
<input type="submit" class="btn btn-info" value="Submit Button">
</div>
您可以href
从此处使用标记行。
<a href="URL" class="btn btn-info" role="button">Button Text</a>
如果您想避免使用CSS对特定设计进行硬编码,而是依靠浏览器的默认按钮,则可以使用以下CSS。
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
}
请注意,它可能无法在IE上运行。
appearance: button
方式可能不同于本机按钮(至少在我刚在Chrome 78上选中时)。
<a>
在chrome中特别不起作用。经过测试,<span>
效果很好。
没有其他答案显示代码,其中链接按钮在悬停时会更改其外观。
这是我为解决此问题所做的工作:
HTML:
<a href="http://www.google.com" class="link_button2">My button</a>
CSS:
.link_button2 {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: solid 1px #1A4575;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
background: #3A68A1;
color: #fee1cc;
text-decoration: none;
padding: 8px 12px;
text-decoration: none;
font-size: larger;
}
a.link_button2:hover {
text-decoration: underline;
background: #4479BA;
border: solid 1px #20538D;
/* optional different shadow on hover
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 1px rgba(0, 0, 0, 0.4);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 1px rgba(0, 0, 0, 0.4);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 1px rgba(0, 0, 0, 0.4);
*/
}
JSFiddle:https://jsfiddle.net/adamovic/ovu3k0cj/
是的,你可以这样做。
这是一个例子:
a{
background:IMAGE-URL;
display:block;
height:IMAGE-HEIGHT;
width:IMAGE-WIDTH;
}
当然,您可以根据需要修改以上示例。重要的是使它显示为块(display:block
)或内联块(display:inline-block
)。
对于基本HTML,您只需在HREF(A)内的图像URL中添加一个src设置的img标签即可。
<a href="http://www.google.com"><img src="http://problemio.com/img/ui/add_problem.png" /></a>
您可以为要显示为按钮的锚元素创建一个类。
例如:
使用图像:
.button {
display:block;
background: url('image');
width: same as image
height: same as image
}
或使用纯CSS方法:
.button {
background:#E3E3E3;
border: 1px solid #BBBBBB;
border-radius: 3px 3px 3px 3px;
}
始终记得用以下方式隐藏文本:
text-indent: -9999em;
一个纯CSS按钮的优秀画廊在这里 ,您甚至可以使用css3按钮生成器
这里有很多款式和选择
祝好运
只需进行常规的css按钮设计,然后将该CSS应用于链接即可(与应用于按钮的方式完全相同)。
例:
<a href="#" class="stylish-button">Some words</a>
<style type="text/css">
.stylish-button {
-webkit-box-shadow:rgba(0,0,0,0.2) 0 1px 0 0;
-moz-box-shadow:rgba(0,0,0,0.2) 0 1px 0 0;
box-shadow:rgba(0,0,0,0.2) 0 1px 0 0;
color:#333;
background-color:#FA2;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border:none;
font-size:16px;
font-weight:700;
padding:4px 16px;
text-shadow:#FE6 0 1px 0
}
</style>
经过Chromium 40和Firefox 36测试
<a href="url" style="text-decoration:none">
<input type="button" value="click me!"/>
</a>
试试这个代码:
<code>
<a href="#" class="button" > HOME </a>
<style type="text/css">
.button { background-color: #00CCFF; padding: 8px 16px; display: inline-block; text-decoration: none; color: #FFFFFF border-radius: 3px;}
.button:hover { background-color: #0066FF; }
</style>
</code>
观看此内容(它将说明如何执行此操作)-https://youtu.be/euti4HAJJfk