html - 将工具提示放在按钮上方的左侧而不是右侧

标签 html css

我试图将按钮的工具提示放在左侧而不是右侧。

左边:

enter image description here

工具栏:

$('#divToolbar').css({
        'top': '0%',
        'left': '0%',
        'z-index': '100',
        'position': 'absolute'
});

工具提示:

.toolbar-vertical-group > .adsk-button > .adsk-control-tooltip 
{
     left: 120%;
     bottom: 25%;
}

但在右边:

enter image description here

  $('#divToolbar').css({
        'top': '0%',
        'left': '96%',
        'z-index': '100',
        'position': 'absolute'
    });
.toolbar-vertical-group > .adsk-button > .adsk-control-tooltip {
    left: -120%;
    bottom: 25%;
}

它被屏幕边缘截断了。我试图添加一些填充或边距,但这似乎没有帮助..

工具栏应该在屏幕的右边缘。

最佳答案

也许尝试获得一些灵感。很难确定你想要实现什么。 编辑:也许是“如何?”会比“什么”更合适

.tools {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 30px;
  height: 120px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .75);
}

.tool {
  position: static;
  width: 80%;
  height: 17%;
  margin: 10%;
  border-radius: 20%;
  background: #FFF;
}

.tooltip {
  left: calc(100% + 5px);
  position: absolute;
  display: none;
  background: rgba(0, 0, 0, .75);
  padding: 2px;
  border: 1px solid #000;
  color: #FFF;
  width: 200px;
}

.tool:hover .tooltip {
  display: block;
}

.right {
  left: auto;
  right: 5px;
}

.right .tooltip {
  left: auto;
  right: calc(100% + 5px);
}
<div class="tools">
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
</div>
<div class="tools right">
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
  <div class="tool">
    <div class="tooltip">Hello there, i am tooltip!
    </div>
  </div>
</div>

关于html - 将工具提示放在按钮上方的左侧而不是右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42759464/

相关文章:

html - 有什么方法可以编辑 "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.css"文件吗?

html - 覆盖内联 CSS Div 标签

javascript - 如何修复 IE6 中的 png 图片问题?

javascript - 如何在 javascript 或 jquery 中获取 div 中的图像高度?

javascript - 我的 svg 贝塞尔曲线的波浪效果这可能吗?

javascript - 将不同 <p> 内的所有数字相乘,然后将其相加

javascript - 检查我的网站是否在另一个选项卡中打开

html - Bootstrap 4 - 具有最大宽度的列表单标签

html - 向右浮动复选框、按钮和输入框

javascript - 按钮事件和点击深度