我正在使用布兰登·皮尔斯的https://css-tricks.com/circular-3d-buttons/,但想要取代“fontello”#39;我选择的图标的图标就像这一个https://image.flaticon.com/icons/svg/451/451694.svg。 我似乎无法完成它!
尝试用' image1'替换图标类。我自己的一类,随机图像作为背景,但它不会显示。
请帮忙!
.nav1 {
list-style: none;
text-align: center;
}
.nav1 li {
position: relative;
display: inline-block;
margin-right: -4px;
}
.nav1 li:before {
content: "";
display: block;
border-top: 1px solid #ddd;
border-bottom: 1px solid #fff;
width: 100%;
height: 1px;
position: absolute;
top: 50%;
z-index: -1;
}
.nav1 a {
display: block;
background-color: #f7f7f7;
background-image: -webkit-gradient(linear, left top, left bottom, from(#f7f7f7), to(#e7e7e7));
background-image: -webkit-linear-gradient(top, #f7f7f7, #e7e7e7);
background-image: -moz-linear-gradient(top, #f7f7f7, #e7e7e7);
background-image: -ms-linear-gradient(top, #f7f7f7, #e7e7e7);
background-image: -o-linear-gradient(top, #f7f7f7, #e7e7e7);
color: #a7a7a7;
margin: 36px;
width: 144px;
height: 144px;
position: relative;
text-align: center;
line-height: 144px;
border-radius: 50%;
box-shadow: 0px 3px 8px #aaa, inset 0px 2px 3px #fff;
}
.nav1 a:before {
content: "";
display: block;
background: #fff;
border-top: 2px solid #ddd;
position: absolute;
top: -18px;
left: -18px;
bottom: -18px;
right: -18px;
z-index: -1;
border-radius: 50%;
box-shadow: inset 0px 8px 48px #ddd;
}
.nav1 a:hover {
text-decoration: none;
color: #555;
background: #f5f5f5;
}
/* Random class I made to replace icon by image */
.image1 {
background: url("https://www.w3schools.com/css/trolltunga.jpg");
width: 100%;
}
HTML
<nav1>
<ul class="nav1">
<li><a href="#" class="image1"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</nav1>
答案 0 :(得分:0)
需要做几件事。这是一个demo。
这是你的图标
.image1:after {
background-image: url("https://image.flaticon.com/icons/svg/451/451694.svg");
background-size: cover;
display: block;
content: '';
width: 100%;
height: 100%;
}
添加这两种样式,使其位于按钮中间而不会溢出
.nav1 a
{
......
box-sizing: border-box;
padding: 17px;
}