html - 如何将文本对象放置在页面下方 90% 的位置?

标签 html css web

我有一个文本对象水平放置在我的页面中间。我想把它放在我页面 90% 的位置。所以如果你正在看我的页面,它会稍微高于底部。我会使用 margin: 330px; 但我很确定它会因用户使用不同的分辨率而有所不同。这是我的代码,如果有人可以提供帮助

HTML:      
  <div id="home">
    <p>Read More</p>
  </div>

CSS:
  #home {
    width: 100%;
    height: 100vh;
    margin: 0px;
    padding: 0px;
    text-align: center;
  }

  #home p {
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 60px;
    color: #FFF;
    margin: 330px;
  }

最佳答案

您可以将 body 设置为 100%,然后使用包装器 div 来容纳 home dive 上方的所有内容。使包装 div 的字体大小减少 90%。

html,
body {
  height: 100%;
  margin: 0px;
}

#main_content {
  min-height: calc(90% - 60px);
  /* Make space for the font size */
}

#home {
  clear: both;
  position: relative;
  width: 100%;
  text-align: center;
}

#home p {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 60px;
  line-height: 60px;
  color: teal;
  margin: 0px;
}
<div id="main_content">
</div>
<div id="home">
  <p>Read More</p>
</div>

关于html - 如何将文本对象放置在页面下方 90% 的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54318359/

相关文章:

javascript - HTML 表格中的嵌套 for 循环

PHP 在变化时下降

html 页脚出现在包装内?

java - 获取应用注解的类

html - 数字输入字段中的两位占位符

css - @font-face 不适用于 Firefox。

html - 创建一个 CSS 外观,使按钮像复选框一样工作

html - 我网站上的内容在屏幕外滚动

git - 如何为 bash 脚本编写基于 Web 的 GUI?

html - 在 html 和 css 中使用悬停创建模糊和差异化边距