What's the mystery of the Bootstrap dropdown menu triangle?

后端 未结 3 984
说谎
说谎 2021-02-05 13:33

I\'m trying to understand the difference between Twitter Bootstrap dropdown menus when they are included within a navbar and when they are not.

When they are included in

3条回答
  •  遥遥无期
    2021-02-05 13:49

    There are two styles applied to the dropdown menu when inside the nav element. They are as follows:

    .navbar .nav > li > .dropdown-menu::before {
       position: absolute;
       top: -7px;
       left: 9px;
       display: inline-block;
       border-right: 7px solid transparent;
       border-bottom: 7px solid #CCC;
       border-left: 7px solid transparent;
       border-bottom-color: rgba(0, 0, 0, 0.2);
       content: '';
     }
     .navbar .nav > li > .dropdown-menu::after {
        position: absolute;
        top: -6px;
        left: 10px;
        display: inline-block;
        border-right: 6px solid transparent;
        border-bottom: 6px solid white;
        border-left: 6px solid transparent;
        content: '';
      }
    

    They create two triangles on top of each other one light grey, the other dark grey. If you use chrome developer tools you can inspect these elements and turn off different styles to get a feel for what they are doing. These styles are not applied without the navbar

提交回复
热议问题