How do I place the red dot before the selected item using CSS?

前端 未结 2 1653
陌清茗
陌清茗 2021-01-29 16:33

I have a dropdown with the following options:

The currently selected item is highlighted in red. And there is a Red Dot placed before the current selection.

Is

2条回答
  •  暖寄归人
    2021-01-29 17:04

    Hi look at my example : https://codepen.io/TokaLazy/pen/JpWEEY

    .category-link.active {
        color: red;
        position: relative;
    }
    
    .category-link.active::before {
        content: '';
        display: block;
        height: .65em;
        width: .65em;
        background: currentColor;
        border-radius: 50%;
        position: absolute;
        top: 50%;
        left: -.65em; // size of bullet 
        transform: translateY(-50%); // vertical alignment
    }
    

提交回复
热议问题