简体   繁体   English

为什么:: after选择器在我的代码中无法正常工作?

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

I use bootstrap 4 for my code. 我的代码使用bootstrap 4。 As I use ::after as below 当我使用:: after如下

.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. 背景颜色应在所有li> a中显示,但仅在导航栏的左侧显示,如以下链接中的屏幕截图所示。 Can someone tell me the solution for this thanks in advance. 有人可以提前告诉我解决方案。

在此处输入图片说明

Add this below css, this will work... 在css下面添加它,这将起作用...

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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