如何在新的div下放置新的div来创建新部分?

时间:2019-05-06 23:03:40

标签: html css html5 css3

我正试图使我的第一个个人投资组合变得疯狂,但是我想让三个部分一个接一个,一个用于项目,一个用于联系。我希望我的第二和第三div看起来像我的第一div。但是,当我把它放到左上角时,如何解决它,使其位于第一个div的下面?

* {
  margin: 0;
  padding: 0;
}

body {
  font-family: Hevetica, sans-serif;
  font-size: 30px;
}


/* navbar beginning */

.navContainer {
  display: flex;
  padding: 25px;
  padding-left: 250px;
  background-color: #66B1E8;
  list-style-type: none;
}

.containerTwo {
  display: flex;
  justify-content: flex-end;
}

li {
  flex: 1;
}

.info {
  padding-right: 75px;
}

a {
  color: black;
  cursor: pointer;
}

a:link {
  text-decoration: none;
}

a:hover {
  color: #889199;
}


/* navbar end */


/* about beginning*/

.main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  position: absolute;
  top: 85px;
  bottom: 0;
  background-color: #37A9BF;
}

.about {
  font-size: 50px;
  margin-bottom: 50px;
}

.description {
  width: 75%;
  word-spacing: 5px;
  line-height: 1.5em;
}

span {
  background-color: #fdff32;
}


/* about end*/


/* projects beginning*/

.projects {
  background-color: #4AE1FF
}


/* projects end*/
<nav>
  <ul class="navContainer">
    <li><a href="#">Christopher A</a></li>
    <div class="containerTwo">
      <li class="info"><a href="#">About</a></li>
      <li class="info"><a href="#">Projects</a></li>
      <li class="info"><a href="#">Contact</a></li>
    </div>
  </ul>
</nav>
<!--END OF NAVBAR-->

<!--ABOUT-->
<div class="main">
  <div class="about">About</div>
  <div class="description">
    <p>
      Hello, my name is Chris A, I am a self taught
      <span>Front End Web Developer</span> currently on my way to become a <span>Full Stack Developer</span>, located in New York City. I am pursuing the opportunity to begin my career in Web Development industry and I am willing to relocate to do so.
    </p>
  </div>
</div>
<!--ABOUT END-->

<!--PROJECTS-->
<div class="Projects">
  sddgdsg
</div>
<!--PROJECTS END-->

1 个答案:

答案 0 :(得分:1)

position:absolute类中删除.main

* {
margin: 0;
padding: 0;
}
body {
font-family: Hevetica, sans-serif ;
font-size: 30px;
}
/* navbar beginning */
.navContainer {
display: flex;
padding: 25px;
padding-left: 250px;
background-color: #66B1E8;
list-style-type: none;
}
.containerTwo{
display: flex;
justify-content: flex-end;
}
li {
flex:1;
}
.info {
padding-right: 75px;
}
a {
color: black;
cursor: pointer;    
}
a:link {
text-decoration: none;
}
a:hover{
color: #889199;
}   
/* navbar end */

/* about beginning*/
.main {
display: flex;
 flex-direction: column;
 justify-content: center;
 align-items: center;
width: 100%;

top: 85px;
bottom: 0;
background-color: #37A9BF;
}
.about {
font-size: 50px;
margin-bottom: 50px;
}
.description{
width: 75%;
word-spacing: 5px;
line-height: 1.5em;
}
span {
background-color: #fdff32;
}
/* about end*/

/* projects beginning*/
.projects {
background-color:#4AE1FF
}
/* projects end*/
<nav>
<ul class="navContainer">
    <li><a href="#">Christopher A</a></li>
    <div class="containerTwo">
    <li class="info"><a href="#">About</a></li>
    <li class="info"><a href="#">Projects</a></li>
    <li class="info"><a href="#">Contact</a></li>
    </div>
</ul>
 </nav>
<!--END OF NAVBAR-->

<!--ABOUT-->
<div class="main">
<div class="about">About</div>
<div class="description">
<p>
    Hello, my name is Chris A, I am a self taught 
<span>Front End Web Developer</span> currently on my way to become 
a <span>Full Stack Developer</span>, located in New York City. I am 
pursuing the opportunity to begin my career in Web Development 
industry 
and I am willing to relocate to do so.
</p>
</div>
</div>
<!--ABOUT END-->

<!--PROJECTS-->
<div class="Projects">
sddgdsg
</div>
<!--PROJECTS END-->