HTML CSS:将Google图标变成不带矩形的按钮

时间:2019-07-07 20:17:59

标签: html css svg button google-material-icons

如何将Google图标变成按钮?但是,不要在按钮周围使用矩形框。图标像素本身就是一个按钮。

.testdelete {
     font-family: Material Icons;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

<span class="testdelete">
 delete
</span>
  

下面的链接在按钮周围放置了一个矩形,这是不需要的。

https://www.w3schools.com/howto/howto_css_icon_buttons.asp

3 个答案:

答案 0 :(得分:2)

为什么不使用标签来模拟按钮?

$( ".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;
}

答案 1 :(得分:0)

html:

<a href="#" class="button">

推特!     

style.css:

.button { 
font-family: Material Icons;
vertical-align:middle; 
cursor: pointer; 
}

.text:hover{  
cursor: pointer; 
}

答案 2 :(得分:0)

尝试一下:-

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
        <meta charset="utf-8"/>
        <title>Icons</title>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    </head>
    <body>
        <i class="fa fa-bars">This a icon without a parent box</i>
    </body>
</html>