HTML 和 CSS 定位

标签 html css

我已经对下面的布局进行了编码,但是在测试时“登录或注册”链接没有定位到页面的右侧。任何帮助表示赞赏。

HTML

<header>
   <h1>Heading</h1>
   <p>A clean, minimal, grid-based layout focusing attention on your work.</p
   <a href="/">Login or Signup</a>
</header>

CSS

body {
  font-family: 'open sans';
  color: #333;
}

header {
  padding: 20px 20px 20px 50px;
}

a {
  color: #333;
  text-decoration: none;
}

h1, h2 {
  font-weight: 300;
}

期望的结果

http://oi38.tinypic.com/161nqrd.jpg

最佳答案

这是一个可行的解决方案:

DEMO

html

<header>
   <a href="/">Login or Signup</a>
   <h1>Heading</h1>
   <p>A clean, minimal, grid-based layout focusing attention on your work.</p>
</header>

CSS

body {
  font-family: 'open sans';
  color: #333;
}

header {
  padding: 20px 20px 20px 50px;
}

header a {
  color: #333;
  text-decoration: none;
  float: right;
  padding-top: 30px;
}

h1, h2 {
  font-weight: 300;
}

关于HTML 和 CSS 定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16129499/

相关文章:

javascript - React 导航栏在屏幕中,即使它不在路由器上

html - 加速图库页面

javascript - 通过 JS 向 SELECT 标签添加选项 .. 样式不是由 CSS 设计的吗?

javascript - 如何防止在 html 中取消选择模糊(焦点丢失)的选定文本

javascript - 使用 Node js 将 css 拆分为 2 个 css 文件并返工

HTML 表格和图像问题 - Firefox

android - html phonegap 安卓 : numeric soft keyboard has next instead of go button

javascript - 实现像 data-reactid 这样的系统

css - 阻止内容因 Bootstrap 中的重叠而被下推

html - Angular NgFor 元素水平显示为标签