带有箭头

时间:2017-06-24 16:44:00

标签: css drop-down-menu tooltip

这真令人沮丧。我试图在个人资料头像的底部添加一个下拉工具提示。不幸的是,似乎没有正常工作。工具提示似乎部分隐藏。如何保持工具提示的具体设计并使其直接显示在图标的底部,箭头指向图标的中间?



body {
  background-color: #36a4b0;
}

#shell-header {
  display: flex;
  height: 46px;
  overflow: hidden;
  z-index: 3;
  opacity: 1;
  white-space: nowrap;
}

.logo-wrapper {
  padding-left: 56px;
}

@media (max-width: 480px) {
  .logo-wrapper {
    padding-left: 1rem;
  }
}

.title-wrapper {
  left: 0;
  right: 0;
  text-align: right;
  flex-grow: 1;
}

.avatar-wrapper {
  padding-right: 56px;
  position: relative;
}

@media (max-width: 480px) {
  .avatar-wrapper {
    padding-right: 1rem;
  }
}

.logo {
  height: 30px;
  line-height: 40px;
  max-width: 96px;
  margin-top: 0.35rem;
}

.log-shellHeaderTitle {
  font-size: 20px;
  line-height: 36px;
  color: #fff;
  text-overflow: ellipsis;
  text-align: center;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  font-weight: inherit;
  margin-left: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}

.log-langButton {
  padding-right: 40px;
}

@media only screen and (max-width: 480px) {
  .log-langButton {
    padding-right: 10px;
  }
}

#log-LangButtSwitch {
  background: transparent;
  cursor: pointer;
  display: block;
  position: relative;
  float: left;
  width: 40px;
  padding: 2px;
  margin-top: 0.25rem;
  border: 2px solid #fff;
  border-radius: 28px;
}

.log-switchHandle {
  display: block;
  background: #fff;
  height: 20px;
  width: 20px;
  z-index: 9999;
  border-radius: 20px;
}

.log-switchLabels {
  position: absolute;
  top: 5px;
  z-index: -1;
  width: 100%;
  font-family: Helvetica, sans-serif;
  font-weight: bold;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}

.log-switchLabels:before {
  content: "EN";
  position: absolute;
  left: 21px;
  font-size: 12px;
}

.log-switchLabels:after {
  content: "DE";
  position: absolute;
  right: 26px;
  font-size: 12px;
}

.fa-user-o:before {
  font-size: 1.375rem;
  color: #fff;
}

.avatar {
  text-align: center;
  margin-top: 0.35rem;
  width: 25px;
}

.log-popover {
  visibility: visible;
  z-index: 460;
  display: block;
  overflow: visible;
  top: 121px;
  left: 375.063px;
  bottom: 10px;
  transition: opacity 0.2s linear;
  color: #333333;
  min-width: 100px;
  box-sizing: border-box;
  outline: none;
  max-width: 100%;
  max-height: 84px;
  min-height: 2rem;
  overflow: hidden;
  background: #ffffff;
  border: none;
  box-shadow: 0 0.625rem 1.875rem 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
}

.log-popover a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.log-popover a:hover {
  background-color: #f0f0f0;
}

.log-popover a:active,
.log-popover a:focus {
  background: #e8eff6;
  outline: 1px dotted #000000;
  outline-offset: -2px;
}

.log-popover:after,
.log-popover:before {
  bottom: 100%;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}

.log-popover:after {
  border-color: rgba(255, 255, 255, 0);
  border-bottom-color: #fff;
  border-width: 10px;
  margin-left: -10px;
}

.log-popover:before {
  border-color: rgba(51, 51, 51, 0);
  border-bottom-color: #333333;
  border-width: 11px;
  margin-left: -11px;
}

.log-toolContainer {
  position: absolute;
  height: 100%;
  width: 100%;
}

<div class="log-container">
  <div id="shell-header">
    <div class="logo-wrapper">
      <img src="https://s-media-cache-ak0.pinimg.com/236x/f7/0a/f6/f70af6169bbe3f8346e64a25d54bafea.jpg" class="logo">
    </div>
    <div class="title-wrapper">
      <div class="log-shellHeaderTitle">Dashboard</div>
    </div>
    <div class="log-langButton">
      <div id="log-LangButtSwitch">
        <span class="log-switchHandle"></span>
        <span class="log-switchLabels"></span>
      </div>
    </div>
    <div class="avatar-wrapper">
      <img class="avatar" src="https://www.talentenportaalhellendoorn.nl/thumbnails/man.png">
      <div class="log-toolContainer">
        <div class="log-popover">
          <a href="#">Profile</a>
          <a href="#about">Log out</a>
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

overflow: hidden;删除#shell-header,因此菜单未被切断,然后使用locate将菜单的容器放在父级的左下角,并使用{{1将其50%的自身宽度+ 50%的头像宽度偏移到图标下方。

&#13;
&#13;
translateX()
&#13;
body {
  background-color: #36a4b0;
}

#shell-header {
  display: flex;
  height: 46px;
  z-index: 3;
  opacity: 1;
  white-space: nowrap;
}

.logo-wrapper {
  padding-left: 56px;
}

@media (max-width: 480px) {
  .logo-wrapper {
    padding-left: 1rem;
  }
}

.title-wrapper {
  left: 0;
  right: 0;
  text-align: right;
  flex-grow: 1;
}

.avatar-wrapper {
  padding-right: 56px;
  position: relative;
}

@media (max-width: 480px) {
  .avatar-wrapper {
    padding-right: 1rem;
  }
}

.logo {
  height: 30px;
  line-height: 40px;
  max-width: 96px;
  margin-top: 0.35rem;
}

.log-shellHeaderTitle {
  font-size: 20px;
  line-height: 36px;
  color: #fff;
  text-overflow: ellipsis;
  text-align: center;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  font-weight: inherit;
  margin-left: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}

.log-langButton {
  padding-right: 40px;
}

@media only screen and (max-width: 480px) {
  .log-langButton {
    padding-right: 10px;
  }
}

#log-LangButtSwitch {
  background: transparent;
  cursor: pointer;
  display: block;
  position: relative;
  float: left;
  width: 40px;
  padding: 2px;
  margin-top: 0.25rem;
  border: 2px solid #fff;
  border-radius: 28px;
}

.log-switchHandle {
  display: block;
  background: #fff;
  height: 20px;
  width: 20px;
  z-index: 9999;
  border-radius: 20px;
}

.log-switchLabels {
  position: absolute;
  top: 5px;
  z-index: -1;
  width: 100%;
  font-family: Helvetica, sans-serif;
  font-weight: bold;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}

.log-switchLabels:before {
  content: "EN";
  position: absolute;
  left: 21px;
  font-size: 12px;
}

.log-switchLabels:after {
  content: "DE";
  position: absolute;
  right: 26px;
  font-size: 12px;
}

.fa-user-o:before {
  font-size: 1.375rem;
  color: #fff;
}

.avatar {
  text-align: center;
  margin-top: 0.35rem;
  width: 25px;
}

.log-popover {
  visibility: visible;
  z-index: 460;
  display: block;
  overflow: visible;
  top: 121px;
  left: 375.063px;
  bottom: 10px;
  transition: opacity 0.2s linear;
  color: #333333;
  min-width: 100px;
  box-sizing: border-box;
  outline: none;
  max-width: 100%;
  max-height: 84px;
  min-height: 2rem;
  overflow: hidden;
  background: #ffffff;
  border: none;
  box-shadow: 0 0.625rem 1.875rem 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
}

.log-popover a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.log-popover a:hover {
  background-color: #f0f0f0;
}

.log-popover a:active,
.log-popover a:focus {
  background: #e8eff6;
  outline: 1px dotted #000000;
  outline-offset: -2px;
}

.log-popover:after,
.log-popover:before {
  bottom: 100%;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}

.log-popover:after {
  border-color: rgba(255, 255, 255, 0);
  border-bottom-color: #fff;
  border-width: 10px;
  margin-left: -10px;
}

.log-popover:before {
  border-color: rgba(51, 51, 51, 0);
  border-bottom-color: #333333;
  border-width: 11px;
  margin-left: -11px;
}

.log-toolContainer {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 100%;
  left: 0;
  transform: translateX(calc(-50% + 12.5px));
}
&#13;
&#13;
&#13;

答案 1 :(得分:0)

删除#hell-header中隐藏的溢出...

body {
  background-color: #36a4b0;
}

#shell-header {
  display: flex;
  height: 46px;
  overflow: visible;
  z-index: 3;
  opacity: 1;
  white-space: nowrap;
}

.logo-wrapper {
  padding-left: 56px;
}

@media (max-width: 480px) {
  .logo-wrapper {
    padding-left: 1rem;
  }
}

.title-wrapper {
  left: 0;
  right: 0;
  text-align: right;
  flex-grow: 1;
}

.avatar-wrapper {
  padding-right: 56px;
  position: relative;
}

@media (max-width: 480px) {
  .avatar-wrapper {
    padding-right: 1rem;
  }
}

.logo {
  height: 30px;
  line-height: 40px;
  max-width: 96px;
  margin-top: 0.35rem;
}

.log-shellHeaderTitle {
  font-size: 20px;
  line-height: 36px;
  color: #fff;
  text-overflow: ellipsis;
  text-align: center;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  font-weight: inherit;
  margin-left: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
  text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}

.log-langButton {
  padding-right: 40px;
}

@media only screen and (max-width: 480px) {
  .log-langButton {
    padding-right: 10px;
  }
}

#log-LangButtSwitch {
  background: transparent;
  cursor: pointer;
  display: block;
  position: relative;
  float: left;
  width: 40px;
  padding: 2px;
  margin-top: 0.25rem;
  border: 2px solid #fff;
  border-radius: 28px;
}

.log-switchHandle {
  display: block;
  background: #fff;
  height: 20px;
  width: 20px;
  z-index: 9999;
  border-radius: 20px;
}

.log-switchLabels {
  position: absolute;
  top: 5px;
  z-index: -1;
  width: 100%;
  font-family: Helvetica, sans-serif;
  font-weight: bold;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}

.log-switchLabels:before {
  content: "EN";
  position: absolute;
  left: 21px;
  font-size: 12px;
}

.log-switchLabels:after {
  content: "DE";
  position: absolute;
  right: 26px;
  font-size: 12px;
}

.fa-user-o:before {
  font-size: 1.375rem;
  color: #fff;
}

.avatar {
  text-align: center;
  margin-top: 0.35rem;
  width: 25px;
}

.log-popover {
  visibility: visible;
  z-index: 460;
  display: block;
  overflow: visible;
  top: 121px;
  left: 375.063px;
  bottom: 10px;
  transition: opacity 0.2s linear;
  color: #333333;
  min-width: 100px;
  box-sizing: border-box;
  outline: none;
  max-width: 100%;
  max-height: 84px;
  min-height: 2rem;
  overflow: hidden;
  background: #ffffff;
  border: none;
  box-shadow: 0 0.625rem 1.875rem 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
}

.log-popover a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.log-popover a:hover {
  background-color: #f0f0f0;
}

.log-popover a:active,
.log-popover a:focus {
  background: #e8eff6;
  outline: 1px dotted #000000;
  outline-offset: -2px;
}

.log-popover:after,
.log-popover:before {
  bottom: 100%;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}

.log-popover:after {
  border-color: rgba(255, 255, 255, 0);
  border-bottom-color: #fff;
  border-width: 10px;
  margin-left: -10px;
}

.log-popover:before {
  border-color: rgba(51, 51, 51, 0);
  border-bottom-color: #333333;
  border-width: 11px;
  margin-left: -11px;
}

.log-toolContainer {
  position: absolute;
  height: 100%;
  width: 100%;
}
<div class="log-container">
  <div id="shell-header">
    <div class="logo-wrapper">
      <img src="https://s-media-cache-ak0.pinimg.com/236x/f7/0a/f6/f70af6169bbe3f8346e64a25d54bafea.jpg" class="logo">
    </div>
    <div class="title-wrapper">
      <div class="log-shellHeaderTitle">Dashboard</div>
    </div>
    <div class="log-langButton">
      <div id="log-LangButtSwitch">
        <span class="log-switchHandle"></span>
        <span class="log-switchLabels"></span>
      </div>
    </div>
    <div class="avatar-wrapper">
      <img class="avatar" src="https://www.talentenportaalhellendoorn.nl/thumbnails/man.png">
      <div class="log-toolContainer">
        <div class="log-popover">
          <a href="#">Profile</a>
          <a href="#about">Log out</a>
        </div>
      </div>
    </div>
  </div>
</div>