【发布时间】:2021-04-06 12:41:28
【问题描述】:
我想在 HTML/CSS 中重现以下项目:
图标实际上来自 font awesome。
这是我目前取得的成就:
https://jsfiddle.net/0Lewug6p/1/
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p"
crossorigin="anonymous"
/>
<link
href="https://fonts.googleapis.com/css2?family=Raleway&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
</head>
<div class="search__filters__option">
<div class="filter__icon"><i class="fas fa-dog"></i></div>
Animaux autorisés
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Raleway", sans-serif;
}
.search__filters__option {
display: flex;
justify-content: flex-start;
align-items: center;
padding-right: 15px;
border-bottom: 2px solid #f2f2f2;
border-top: 2px solid #f2f2f2;
border-right: 2px solid #f2f2f2;
text-align: center;
border-radius: 20px;
font-weight: bold;
margin-right: 10px;
}
.search__filters__option:hover {
background-color: #deebff;
color: #0065fc;
cursor: pointer;
}
.filter__icon {
margin-right: 10px;
height: 35px;
width: 35px;
border-radius: 50%;
color: #0065fc;
background-color: #deebff;
display: flex;
justify-content: center;
align-items: center;
}
我的代码有两个问题:
1- 它与图像中的内容不完全匹配,(例如,彩色圆圈的大小不正确)。
2- 我不知道我的代码是否干净,因为我对 CSS 还是很陌生,想学习最佳实践。
提前感谢您的帮助和解释!
【问题讨论】:
-
寻求代码帮助的问题必须包括在问题本身中重现它所需的最短代码,最好是在堆栈片段中。尽管您已经提供了一个链接,但如果它变得无效,那么您的问题对于未来遇到同样问题的其他 SO 用户将毫无价值。见Something in my website/example doesn't work can I just paste a link。
-
我觉得你已经有了正确的代码 :) 我检查了它.. 看起来很相似!如果您还有什么想法,请告诉我:)
-
@ImranRafiqRather 结果并不完全相同,例如圆圈的顶部和底部与周围的灰色边框之间有一个小间隙。
-
当您说“例如,彩色圆圈的大小不合适)。你到底想指出什么。 :)
标签: html css font-awesome