【问题标题】:CSS Margin-right has no effect?CSS Margin-right 没有效果?
【发布时间】:2019-03-02 11:47:25
【问题描述】:

在下面的程序中,为什么margin-right 值(+ve/-ve)对工具提示文本没有影响? margin-left 工作正常,但 margin-right 没有影响?谢谢

.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  /* Position the tooltip */
  position: absolute;
  top: 100%;
  margin-right: 100px;
}
<h2>Bottom Tooltip</h2>
<p>Move the mouse over the text below:</p>

<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>

【问题讨论】:

标签: css position margin


【解决方案1】:

默认情况下,HTML 元素与其父元素的左上角对齐,在本例中为.tooltip。添加margin-right 将立即推送元素。但是.tooltip 之后没有元素,因此没有效果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多