【问题标题】:How Can I Put Text On the Right Top Corner [duplicate]如何将文本放在右上角[重复]
【发布时间】:2019-03-29 18:39:11
【问题描述】:

我需要帮助将文字放在右上角!

我在 Google、StackOverflow 和 youtube 上搜索

<html>
    <a href=login.html>LogIn</a>
</html>

我希望我可以将登录文本放在右上角!

【问题讨论】:

    标签: html css


    【解决方案1】:

    要将链接定位在视口的右上角,有几种方法。

    固定定位

    a {
      position: fixed;
      top: 0;
      right: 0;
    }
    &lt;a href=login.html&gt;LogIn&lt;/a&gt;

    绝对定位

    a {
      position: absolute;
      top: 0;
      right: 0;
    }
    &lt;a href=login.html&gt;LogIn&lt;/a&gt;

    CSS 网格(是的,有点矫枉过正)

    body {
      display: grid;
      justify-items: end;
    }
    &lt;a href=login.html&gt;LogIn&lt;/a&gt;

    弹性盒

    body {
      display: flex;
      justify-content: flex-end;
    }
    &lt;a href=login.html&gt;LogIn&lt;/a&gt;

    表格定位

    a {
      display: table;
      margin-left: auto;
    }
    &lt;a href=login.html&gt;LogIn&lt;/a&gt;

    【讨论】:

      【解决方案2】:

      为什么不直接使用 css?

      a#login {
        position: fixed;
        right: 0;
        top: 0;
      }
      &lt;a id="login" href=login.html&gt;LogIn&lt;/a&gt;

      【讨论】:

        【解决方案3】:

        a{
          position:fixed;
          top: 0;
          right: 0;
        }
        &lt;html&gt;&lt;a href=login.html&gt;LogIn&lt;/a&gt;&lt;/html&gt;

        &lt;html&gt;&lt;div style="text-align:right"&gt;&lt;a href=login.html&gt;LogIn&lt;/a&gt;&lt;/div&gt;&lt;/html&gt;

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2010-09-09
          • 2021-09-08
          • 1970-01-01
          • 1970-01-01
          • 2020-11-04
          • 2013-01-01
          • 1970-01-01
          • 2011-10-12
          相关资源
          最近更新 更多