我讀到過使用一些叫做字體牛逼的軟件在HTML中添加圖標,但我不完全確定如何在我的例子中實現這一點。我做了一個按鈕的基本頁面,但想添加每個按鈕的相關圖標。以下是我目前為止的代碼:
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
}
.social-buttons {
margin-top: 20px;
}
.social-buttons button {
display: inline-block;
padding: 10px 20px;
margin: 10px;
background-color: #007bff;
color: #fff;
font-size: 16px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.social-buttons button:hover {
background-color: #0056b3;
}
<!DOCTYPE html>
<html>
<head>
<title>Social Media Buttons</title>
</head>
<body>
<div class="container">
<h1>Social Media Buttons</h1>
<div class="social-buttons">
<button onclick="window.location.>Facebook</button>
<button onclick="window.location.>Twitter</button>
<button onclick="window.location.>Instagram</button>
<button onclick="window.location.>LinkedIn</button>
<button onclick="window.location.>YouTube</button>
</div>
</div>
</body>
</html>
是的,字體awesome可以用來添加各種圖標,要實現它,你可以在你的代碼中添加以下內容。進一步的教程可以在這里找到:https://fontawesome.com/docs/web/add-icons/how-to
實現庫:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
然后按如下方式更改每個按鈕的代碼(例如facebook):
<button onclick="window.location.">
<i class="fab fa-facebook-f"></i> Facebook
完整代碼如下:
<!DOCTYPE html>
<html>
<head>
<title>Social Media Buttons</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
}
.social-buttons {
margin-top: 20px;
}
.social-buttons button {
display: inline-block;
padding: 10px 20px;
margin: 10px;
background-color: #007bff;
color: #fff;
font-size: 16px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.social-buttons button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Social Media Buttons</h1>
<div class="social-buttons">
<button onclick="window.location.">
<i class="fab fa-facebook-f"></i> Facebook
</button>
<button onclick="window.location.">
<i class="fab fa-twitter"></i> Twitter
</button>
<button onclick="window.location.">
<i class="fab fa-instagram"></i> Instagram
</button>
<button onclick="window.location.">
<i class="fab fa-linkedin-in"></i> LinkedIn
</button>
<button onclick="window.location.">
<i class="fab fa-youtube"></i> YouTube
</button>
</div>
</div>
</body>
</html>