html - 如何在 CSS 中正确定位和缩放这些元素?

标签 html css position scale glyphicons

我已经能够使用 html 和 css 在我的网页中正确定位和缩放一些元素,但是由于定位规则,我已经陷入了如何使用另外两个元素继续这个操作。

图片中的人字形图标必须位于标题为“向下滚动”的最后一段下方,而且我还希望它随屏幕尺寸缩放,因为我已经成功地对其他文本/元素进行了缩放,如您所见:

enter image description here

这是 html:

<!DOCTYPE html>
<html>
  <head>
    <title>myWebpage</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <link rel="shortcut icon" type="image/x-icon" href="pencil.ico" />

    <link href="css/font-awesome.min.css"rel="stylesheet">

    <link href="main-sanctuary.css" rel="stylesheet" type="text/css">
  </head>

  <body>
      <header>
        <h1>Hellloooooooooooooo!</h1>
        <p id="first-p">Welcome All!<br>Make Yourself at home.</p>
        <p id="secondary-p">Scroll down.</p>
        <button id="logBtn">Log In</button>
        <button id="signBtn">Sign Up</button>
        <i class="fa fa-chevron-down fa-4x"></i>

      </header>
    </body>
 </html>

这是CSS:

* {
  margin:0;
  padding:0;
}

body,html {
  height: 100%;
  background: honeydew;
}
/* Header*/
header {
  height: 100vh;
  background-image: url(https://s3-us-west-2.amazonaws.com/assests/books-apple.jpg);
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  text-align: center;
  position:relative;
}
h1 {
  color: honeydew;
  font-family: "Helvetica Neue";
  font-size : 7.5vw;
  margin-bottom: 30px;
}
#first-p {
  color: honeydew;
  font-family: "Helvetica Neue";
  font-weight: lighter;
  font-style: normal;
  font-size : 3.5vw;
  margin-bottom: 50px;

}
#secondary-p {
  position: inherit;
  color: #FFD700;
  font-family: "Helvetica Neue";
  font-weight: lighter;
  font-style: normal;
  font-size : 2vw;
  margin-bottom: -90px;

}
.fa {
  color: #FFD700;

}

那么如何在我的网页上将 .fa 正确放置在 #secondary-p 下并缩放它呢?

最佳答案

只需从 #secondary-p 中删除 margin-bottom : -90px;,这将使 Cheveron 图标位于 Scroll Down 下方(#sencondary-p).

为了缩放 Cheveron 图标,将 font-size 添加到它,并使用 vw 中的值。像这样:-

.fa{
  color : #FFD700;
  font-size : 4vw;
}

演示 is here.

更新

为了将它们向下移动一点,将 .fa 元素和 #sencondary-p 元素包装在 div 中并给出div 一些 margin-top。像这样:-

HTML :-

<div id="wrapper">
  <p id="sencondary-p">Scroll Down</p>
  <i class = "fa fa-chevron-down fa-4x"></i>
</div>

CSS :-

#wrapper{
  margin-top : 100px; /*Increase the value to shift more down*/
}

查看更新的演示 here.

关于html - 如何在 CSS 中正确定位和缩放这些元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35253082/

相关文章:

jsf - 在p:wizard中重新定位导航按钮

r - 在 ggplot 中将 x 轴标签指向内

html - 并排定位标签和输入

javascript - 是否可以仅使用 JavaScript 而无需使用 HTML 将动态链接插入到电子邮件中? (使用Google脚本发送电子邮件)

javascript - 为什么我的 HTML5 视频控制按钮不能与 Javascript 配合使用?

javascript - 使用动态颜色向图例添加标签

javascript - 如何使范围 slider 的左侧与 slider 右侧的颜色不同?

javascript - 使用 php 从表单生成 Word 文件。

javascript - 显示/隐藏 div 以使用 jquery 进行过滤

css - IE9中的子导航被推到导航之上