简体   繁体   中英

Why ::after selector is not working properly in my code?

I use bootstrap 4 for my code. As I use ::after as below

.navbar-light .navbar-nav > li >a::after{
    content: " ";
    height: 50px;
    width: 10%;
    background-image: linear-gradient(to right,#1E8BC3,rgb(162, 214, 240)) !important;
    position: absolute;
    top: 0;
    left: 0;
    z-index:8;
}

The background color should be shown in all li >a but it shown only left side of the navbar as screenshot in below link. Can someone tell me the solution for this thanks in advance.

在此处输入图片说明

Add this below css, this will work...

.navbar-light .navbar-nav > li {
  position: relative;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM