猿问

我如何应用 css 边框和 css 填充

我需要有条件地突出显示现有应用程序的菜单项。为了突出显示该项目,我为该特定项目使用了底部边框。但是已经有一个正在应用的填充并且突出显示的行需要在底部(附上图像以供参考)


.menulist {

  background: white;

  color: black;

  font-family: 'Times New Roman', Times, serif;

  transition: height .3s;

  z-index: 9;

  width: 100%;

}


.menulist .menulist-menu-bar {

  display: flex;

  align-items: center;

  flex-wrap: wrap;

  padding: 8px;

  justify-content: flex-start;

  position: relative;

  justify-content: inherit;

}


.menulist .menulist_nav {

  padding-left: 0;

  list-style: none;

  font-size: 14px;

  line-height: 1.71;

  font-weight: normal;

  margin: 0;

  display: flex;

  flex-wrap: wrap;

  align-content: center;

  align-items: stretch;

  height: 100%;

}


.menulist_bottom_border {

  border-bottom: 2px solid;

  border-color: gray;

  margin-left: 20px;

}

<header class="menulist">

  <div class="menulist-menu-bar">

    <div>

      <ul class="menulist_nav">

        <div class="menulist_bottom_border">nav1</div>

        <div>nav2</div>

        <div>nav3</div>

      </ul>

    </div>

  </div>

</header>


慕盖茨4494581
浏览 140回答 2
2回答

鸿蒙传说

兄弟,它正在工作。看到这个:-.menulist {&nbsp; &nbsp; &nbsp; background: white;&nbsp; &nbsp; &nbsp; color: black;&nbsp; &nbsp; &nbsp; font-family: 'Times New Roman', Times, serif;&nbsp; &nbsp; &nbsp; transition: height .3s;&nbsp; &nbsp; &nbsp; z-index: 9;&nbsp; &nbsp; &nbsp; width: 100%;&nbsp; &nbsp; }&nbsp; &nbsp; .menulist .menulist-menu-bar {&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; align-items: center;&nbsp; &nbsp; &nbsp; flex-wrap: wrap;&nbsp; &nbsp; &nbsp; padding: 8px;&nbsp; &nbsp; &nbsp; justify-content: flex-start;&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; }&nbsp; &nbsp; .menulist .menulist_nav {&nbsp; &nbsp; &nbsp; padding-left: 0;&nbsp; &nbsp; &nbsp; list-style: none;&nbsp; &nbsp; &nbsp; font-size: 14px;&nbsp; &nbsp; &nbsp; line-height: 1.71;&nbsp; &nbsp; &nbsp; font-weight: normal;&nbsp; &nbsp; &nbsp; margin: 0;&nbsp; &nbsp; &nbsp; display: flex;&nbsp; &nbsp; &nbsp; flex-wrap: wrap;&nbsp; &nbsp; &nbsp; align-content: center;&nbsp; &nbsp; &nbsp; align-items: stretch;&nbsp; &nbsp; &nbsp; height: 100%;&nbsp; &nbsp; }&nbsp; &nbsp; .menulist_bottom_border {&nbsp; &nbsp; &nbsp; border-bottom: 2px solid;&nbsp; &nbsp; &nbsp; border-color: gray;&nbsp; &nbsp; &nbsp; margin-left: 20px;&nbsp; &nbsp; }<header class="menulist">&nbsp; <div class="menulist-menu-bar">&nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; <ul class="menulist_nav">&nbsp; &nbsp; &nbsp; &nbsp; <div class="menulist_bottom_border">nav1</div>&nbsp; &nbsp; &nbsp; &nbsp; <div class="menulist_bottom_border">nav2</div>&nbsp; &nbsp; &nbsp; &nbsp; <div class="menulist_bottom_border">nav3</div>&nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; </div>&nbsp; </div></header>您看到了意想不到的事情,因为只有一个 div 具有类菜单列表底部边框。由于大多数 elems 具有 flex display 属性,所以它看起来像那样。

白猪掌柜的

正如我所理解的,你的问题解释了我可能对你有帮助的想法。文本和边框底部之间的填充是因为&nbsp;line-hight: 1.71;图像中显示的黄色填充是因为在 class 上应用了填充menulist-menu-bar。如果您想删除其中任何一个,那么您可以使用这些值来获得所需的输出。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答