CSS3 arrow hyperlink

淺唱寂寞╮ 提交于 2019-12-01 14:22:38

You should set the top explicitly to 0 for the :after element, and also remember to set the position:relative for the div element so that the absolute positioning works as expected:

.readmore > div::after {
   ...
   top:0;
}

.readmore > div {
   ...
   position:relative;
}

Fiddle

NOTE: The negative margin-top should be removed. The cause of your problem is you use negative margin-top (maybe by trial and error until it looks OK in FF), but the position also depends on the top and left. The default values of these properties are implemented differently by different browsers, the only solution to set it in order is explicitly set the top, left and remember the rule to determine the containing block for the absolute positioned element. (the nearest ancestor which has position as absolute or relative).

Try this code -- >
HTML :

<div>content</div>
<a href="#">Link</a>
<div>content</div>

CSS :

a{
    padding:10px;
    background:#2ecc71;
    display:inline-block;
    position:relative;
}
a:hover{
    background:orange;
}
a:hover:after{
   border-left: 20px solid orange;
}
a:after {
display: inline-block;
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #2ecc71;
position: absolute;
right:-20px;
top:0;

}  

JS FIDDLE DEMO

The border width and the right and top positions can be tweaked according to your needs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!