-1

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

我在 Google、StackOverflow 和 youtube 上搜索

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

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

4

3 回答 3

1

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

固定定位

a {
  position: fixed;
  top: 0;
  right: 0;
}
<a href=login.html>LogIn</a>

绝对定位

a {
  position: absolute;
  top: 0;
  right: 0;
}
<a href=login.html>LogIn</a>

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

body {
  display: grid;
  justify-items: end;
}
<a href=login.html>LogIn</a>

弹性盒

body {
  display: flex;
  justify-content: flex-end;
}
<a href=login.html>LogIn</a>

表定位

a {
  display: table;
  margin-left: auto;
}
<a href=login.html>LogIn</a>

于 2019-03-29T08:19:24.213 回答
0

为什么不直接使用 css?

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

于 2019-03-29T08:19:33.580 回答
-1

a{
  position:fixed;
  top: 0;
  right: 0;
}
<html><a href=login.html>LogIn</a></html>

<html><div style="text-align:right"><a href=login.html>LogIn</a></div></html>

于 2019-03-29T08:27:28.443 回答