HTML CSS: 将 Google 图标变成没有矩形包围的按钮
HTML CSS: Make Google Icon into Button without Rectangle around it
如何将 Google 图标制作成按钮?但是,不希望按钮周围有一个矩形框。图标像素本身就是一个按钮。
.testdelete {
font-family: Material Icons;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<span class="testdelete">
delete
</span>
Link 下面在按钮周围放置了一个矩形,不需要的东西。
html:
<a href="#" class="button">
鸣叫!
style.css:
.button {
font-family: Material Icons;
vertical-align:middle;
cursor: pointer;
}
.text:hover{
cursor: pointer;
}
为什么不用标签来模拟按钮呢?
$( ".testdelete" ).click(function() {
$("p").hide();
});
.testdelete {
font-family: Material Icons;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<a class="testdelete">
delete
</a>
<p class="hi">To be deleted</p>
您也可以使用 <button>tweet</button>
并使用 css 处理背景和边框移除:
.button {
background: none;
border: none;
color: black;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>
</body>
</html>
如何将 Google 图标制作成按钮?但是,不希望按钮周围有一个矩形框。图标像素本身就是一个按钮。
.testdelete {
font-family: Material Icons;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<span class="testdelete">
delete
</span>
Link 下面在按钮周围放置了一个矩形,不需要的东西。
html:
<a href="#" class="button">
鸣叫!
style.css:
.button {
font-family: Material Icons;
vertical-align:middle;
cursor: pointer;
}
.text:hover{
cursor: pointer;
}
为什么不用标签来模拟按钮呢?
$( ".testdelete" ).click(function() {
$("p").hide();
});
.testdelete {
font-family: Material Icons;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<a class="testdelete">
delete
</a>
<p class="hi">To be deleted</p>
您也可以使用 <button>tweet</button>
并使用 css 处理背景和边框移除:
.button {
background: none;
border: none;
color: black;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>
</body>
</html>