javascript - Adding dot above navigation list elements on hover - Stack Overflow

I am trying to add a hover effect on my navigation links in my navbar to be a simple filled dot above t

I am trying to add a hover effect on my navigation links in my navbar to be a simple filled dot above the highlighted list item. I cannot seem to get anything to work. I had been trying the :before and :after css pseudo selectors. I did get a line to work using a border property as well. Is there a simple way to do this.

html

<div class="navbar">
    <ul>
        <li class="active"><a href="#">link 1></a></li>
        <li><a href="#">link 2></a></li>
        <li><a href="#">link 3></a></li>
        <li><a href="#">link 4></a></li>
    </ul>
</div>

I am trying to add a hover effect on my navigation links in my navbar to be a simple filled dot above the highlighted list item. I cannot seem to get anything to work. I had been trying the :before and :after css pseudo selectors. I did get a line to work using a border property as well. Is there a simple way to do this.

html

<div class="navbar">
    <ul>
        <li class="active"><a href="#">link 1></a></li>
        <li><a href="#">link 2></a></li>
        <li><a href="#">link 3></a></li>
        <li><a href="#">link 4></a></li>
    </ul>
</div>
Share Improve this question asked May 26, 2014 at 17:26 user1881482user1881482 7462 gold badges17 silver badges35 bronze badges 1
  • 1 Of course it is simple using before/after elements … add in a little absolute positioning, and you”re there already. – C3roe Commented May 26, 2014 at 17:36
Add a ment  | 

1 Answer 1

Reset to default 5

Is this what you need ?

ul li:hover:before {
    content: "";
    position: absolute;
    top: -15px;
    background: red;
    width: 15px;
    height: 15px;
    border-radius: 100%;
    left:calc(50% - 8px);
}

and the fiddle.

http://jsfiddle/f7RrW/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745463873a4628829.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信