2016-04-26 60 views
2

在本頁面看看:http://codepen.io/abdulahhamzic/pen/WwgXRW如何使新部分立即放在前一部分下方?

這裏的HTML:

<!doctype html> 
<html> 
<head> 
</head> 
<body> 
<header> 
    <nav> 
    <ul> 
     <li><a href="#info">Info</a></li> 
     <li><a href="#portfolio">Portfolio</a></li> 
     <li><a href="#">Contact</a></li> 
    </ul> 
    </nav> 
</header> 
<section id="info"> 
    <p class="info"> 
    <br> 
    <br> 
    <br> 
    My name is Abdulah Hamzic. I am a beginner front-end web developer with not a lot of experience, but passionate about web-development and ready to learn new things everyday. I have completed the <a href="https://www.coursera.org/account/accomplishments/certificate/A5QYJS26WJ4E" target="_blank"><i>HTML, CSS and JavaScript</i></a> course by the Hong Kong University of Science and Technology and I'm currently doing the University of Michigan <a href="https://www.coursera.org/specializations/web-design" target="_blank"><i>Web Design for Everybody</i></a> specialization, plus the <a href="http://freecodecamp.com/" target="_blank">Free Code Camp</a> path. I haven't built many projects, but you can check some of my first pens here on CodePen below. 
    </p> 
    <img id="myself" src="https://scontent-fra3-1.cdninstagram.com/t51.2885-15/e15/10453774_522901187836495_1728850695_n.jpg"/> 
</section> 
<section id="portfolio"> 
    <h3>This is my portfolio: 
    </h3> 
    <img src=""> 
</section> 
</body> 
</html> 

有沒有一種方法,使第二部分(#portfolio)馬上去上一節(#info)以下,且沒有在導航欄所在頁面的頂部?任何人都請幫忙!

+1

當然......不要使用'position:absolute'..simple。 –

+0

我沒有使用位置:絕對雖然 –

+0

當然你做了... #info div。 –

回答

0

在這種情況下,雖然position:absolute是問題,引導你的是增加利潤的標題

我建議你聯繫的一部分或者使用Bootstrap佈局方法和類或覆蓋標題邊距

.h1, .h2, .h3, h1, h2, h3 { 
    margin-top: 0px; 
    margin-bottom: 0px; 
} 

我會建議前者。

Codepen Demo