我參加了Brad Traversy的 50 個專案 50 天課程。在Day 26 - Double Vertical Slider中,他使用的Font Awesome CDN是5.15.1版本,這是一個非常過時的版本。我使用的是6.1.1版,但即使我嘗試除錯它,我的圖示也沒有加載。我想要分別在我的向下按鈕和向上按鈕類中的向下箭頭和向上箭頭圖示。
這是我的代碼:
@import url('https://fonts.googleapis.com/css?family=Open Sans');
* {
box-sizing: border-box;
}
body {
font-family: 'Open Sans', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-iBBXm8fW90 nuLcSKlbmrPcLa0OT92xO1BIsZ ywDWZCvqsWgccV3gFoRBv0z 8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="style.css" />
<title>Vertical Slider</title>
</head>
<body>
<div class="slider-container">
<div class="left-slide"></div>
<div class="right-slide"></div>
<div class="action-buttons">
<button class="down-button">
<i class="fa-solid fa-arrow-down"></i>
</button>
<button class="up-button">
<i class="fa-solid fa-arrow-down"></i>
</button>
</div>
</div>
<script src="https://kit.fontawesome.com/3cff899477.js"></script>
<script src="script.js"></script>
</body>
</html>
謝謝你!
uj5u.com熱心網友回復:
它與integrity
屬性有關:
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
integrity="sha512-iBBXm8fW90 nuLcSKlbmrPcLa0OT92xO1BIsZ ywDWZCvqsWgccV3gFoRBv0z 8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
洗掉它,它應該可以作業:
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
uj5u.com熱心網友回復:
現在你不需要從 font awesome 下載任何檔案了。您可以使用套件 1-訪問網站。2-登錄。3-在 gmail 收件箱中發送工具包。(套件是代碼 javascre) 4-轉到 html 檔案并在 title 中提取代碼。只要........
uj5u.com熱心網友回復:
您的完整性代碼很糟糕。只需將其替換為來自https://cdnjs.com/libraries/font-awesome的新生成鏈接
不要洗掉完整性屬性請參閱此處了解原因:https ://stackoverflow.com/a/49061277/8565010
@import url('https://fonts.googleapis.com/css?family=Open Sans');
* {
box-sizing: border-box;
}
body {
font-family: 'Open Sans', sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}
.down-button {
display: block;
width: fit-content;
height: fit-content;
padding: 2rem;
margin: 0 auto 1rem auto;
}
.up-button {
display: block;
width: fit-content;
height: fit-content;
padding: 2rem;
margin: 0 auto 1rem auto;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="style.css" />
<title>Vertical Slider</title>
</head>
<body>
<div class="slider-container">
<div class="left-slide"></div>
<div class="right-slide"></div>
<div class="action-buttons">
<button class="down-button">
<i class="fa-solid fa-arrow-down"></i>
</button>
<button class="up-button">
<i class="fa-solid fa-arrow-up"></i>
</button>
</div>
</div>
<script src="https://kit.fontawesome.com/3cff899477.js"></script>
<script src="script.js"></script>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/496887.html
上一篇:使用flex和align問題將兩個元素定位在右側和一個左側
下一篇:隱藏標簽邊框