我正在尝试创建以div为中心的链接。
链接应该是一个圆圈,并且箭头指向上方。
基本上我需要一个"进入页面"链接...
我有以下内容:
<div>
<a href="#"></a>
</div>
我有以下CSS:
a {
background: #4679BD;
border-radius: 50%;
display: block;
height: 80px;
width: 80px;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
}
我是否需要图像来获得箭头。还有其他选择吗?
当我在A标签内插入一个字母时,该字母会在圆圈之外。
最后,这可以做出回应吗?
答案 0 :(得分:4)
您可以摆脱包装div(以及带前缀的border-radius
),并使用pseudo-elements代替content
CSS属性中的箭头字符。
或使用
\25b2
(和50px字体大小):
<a href="#"></a>
a {
background: #4679BD;
text-decoration:none; /* Remove that ugly underlining */
border-radius: 50%;
display: block;
height: 80px;
width: 80px;
}
a::after {
content:"\2191"; /* The code for the arrow : see the reference */
display: block;
color: white;
font-weight: bold;
font-size: 60px; /* Adjust for your needs */
text-align: center;
}
A list of useful HTML and CSS entities!
响应?使用相对于字体大小的大小(如em
,rem
...)而不是px,是的。
响应屏幕尺寸本身?不,AFAIK。
答案 1 :(得分:0)
尝试使用html向上箭头实体↑
,以及一些样式:
div {
width: 40px;
height: 40px;
border-radius: 50%;
background: #f2f2f2;
text-align: center;
line-height: 40px; // needs to be same as height
margin: 100px auto;
}
div a {
display: block;
width: 100%;
height: 100%;
text-decoration: none;
color: #333;
}
请参阅codepen
答案 2 :(得分:0)
你可以使用这样的边框制作带有css的三角形,但是如果你想要实际的箭头,那么使用图像可能会更容易。
这是你正在寻找的吗?
我把你的css移到div并给了这个样式:
a {
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 25px solid black;
}
然后稍微调整三角形的位置。
编辑:
你可以像这样添加悬停:
a:hover{
border-bottom: 25px solid red;
}
答案 3 :(得分:0)
<a href="#">→</a>
a {
display: block;
font-size: 18px;
color: rgba(255,255,255,0.4);
position: absolute;
right: 15px;
bottom: 15px;
border: 2px solid rgba(255,255,255,0.3);
border-radius: 50%;
width: 30px;
height: 30px;
line-height: 22px;
text-align: center;
font-weight: 700;
}
a:hover {
color: #fff;
border-color: #fff;
}