将文本与页眉的角落对齐

时间:2017-09-29 01:49:11

标签: css wordpress

我想将标题文本(蓝色背景)与标题的右下角对齐,以便无论设备如何(始终如一),它始终处于该位置。到目前为止,在我测试过的每台设备上看起来都不同,所以我很难过。我在这一天都花了很多时间,无处可去。有人可以帮忙吗?

谢谢!

[为隐私而删除的网址]

P.S。我已阅读CSS Positioning relative to corner of Div并试图实施它,但仍然卡住了!

1 个答案:

答案 0 :(得分:1)

您可以将position: relative提供给父元素,将position: absolute; right: 0; bottom: 0;提供给子元素,子视图将相对于父元素(它将位于右下角)。这是一个例子:

.wrapper {
  width: 100%;
  height: 150px;
  position: relative;
  background-color: violet;
}

.target {
  position: absolute;
  width: 100px;
  height: 100px;
  background-color: black;
  color: white;
  text-align: center;
  line-height: 100px;
  right: 0;
  bottom: 0;
}
<div class="wrapper">
  <div class="target">TARGET</div>
</div>