【发布时间】:2015-11-26 22:23:20
【问题描述】:
我仍然难以使用 CSS 定位 HTML 元素。我了解基础知识,元素主要显示为块或内联;但是,当涉及到实际编码网站时,我会感到困惑。我在下面包含了我的 HTML 编码,我对此非常满意。我现在开始使用 CSS 设置代码样式。我想在页面顶部创建一个导航栏;为此,我使用了 CSS 编码(也在下方)。
首先,我将列表显示为内联块。其次,我将我的标题向左浮动,我的列表向右浮动,这一切看起来都很好。我的困惑是为什么我的班级“滑块”会在这两个元素之间向上移动?
我非常感谢一个解决方案,但更重要的是,如果您能解释实际理论和功能来解释为什么会发生这种情况,我将不胜感激。我自己的理论是,通过浮动这两个元素,它们已经从页面的“正常”流程中移除,允许页面上的下一个元素移动到留下的空白空间?同样,我希望有一个解决方案,但更多的是我想自己了解它背后的理论,这样我以后就可以自己解决类似的问题了。
<style>
.nav li {
display: inline-block;
}
.nav ul {
float: right;
}
.nav h1 {
float: left;
}
</style>
<div class="nav">
<h1>Resume</h1>
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>Skills</li>
<li>Experience</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="slider">
<h2>Andrew Hardiman</h2>
<p>Webdesigner & Developer</p>
<p>Read More</p>
<p>HTML</P>
<p>css</P>
<h3>I design and develop amazing websites that are sleek, easy-to-navigate and exiting to use.</h3>
<p>Work with us to plan your digital marketing mix and achieve better results online.</p>
</div>
</div>
<div class="Portfolio">
<div class="container">
<h3>Portfolio</h3>
<img src="https://download.unsplash.com/photo-1423655156442-ccc11daa4e99">
<h3>Client</h3>
<h4>JPMorgan</h4>
<h3>Role in Project</h3>
<h4>Project Lead</h4>
<h3>Project Included</h3>
<h4>Mobile and Web Interface</h4>
</div>
</div>
<div class="skills">
<div class="container">
<h3>Skills</h3>
<p>I am a bit of a hybrid Web Developer and like to utilise my skills both front and back end as well
as keep in touch with my creative side designing websites</p>
<p>html</P>
<p>CSS</p>
<p>JavaScript</p>
<p>jQuery</P>
</div>
</div>
<div class="Experience">
<div class="container">
<h3>Experience</h3>
<h4>Work Experience</h4>
<p>Blah blah blah, professional with this and that<p>
<h5>Royal National Lifeboat Institution</h5>
<p>Coastal Support Officer, blah blah blah<p>
<h5>Pioneer Business Systems</h5>
<p>blah d, blah d, blah</p>
<h5>JPMorgan Chase</h5>
<p>Some more blah d, blah</p>
</div>
</div>
<div class="wrap">
<div class="container">
<img src="https://download.unsplash.com/photo-1424296308064-1eead03d1ad9">
<h3>Andrew Hardiman</h3>
<p>I have worked for one of the top Investment Banks in the world (JPMorgan) and loved
every minute of it!</p>
<p>Today, I have left the world of high-finance to fulfil my curiosity in the freelance
arena which has been amazing so far and I can't think of why I did not taken the plunge sooner</p>
</div>
</div>
<div class="contact">
<div class="container">
<div id="Username"></div>
<div id="Email"></div>
<div id="Cost or your project"></div>
<div id="Timeline"></div>
<h4>LOCATION</h4>
<p>Flat 1, 29 Markham Road, Bournemouth, BH9 1HZ</p>
<h4>I AM SOCIAL</h4>
<ul>
<li>Facebook</li>
<li>Twitter</li>
<li>Google+</li>
<li>Linkedin</li>
<li>Flickr</li>
</ul>
<div class="Send>
<a href="#">Send</a>
</div>
</div>
</div>
<div class="location">
</div>
<div class="top-footer">
<div class="footer-menu">
<h4>Menu</h4>
<ul>
<li>Home</li>
<li>Portfolio</li>
<li>Skills</li>
<li>Experience</li>
<li>Contact</li>
</UL>
</div>
<div class="footer-archives">
<h4>Archives</h4>
<ul>
<li>March 2014</li>
<li>April 2014</li>
<li>May 2014</li>
<li>June 2014</li>
<li>July</li>
</ul>
</div>
<div class="widget">
<p>Not really sure what this is for, you'll need to find out</p>
</div>
<div class="follows">
<h4>Follows</h4>
<ul>
<li><a href="#"></li>
<li><a href="#"></li>
<li><a href="#"></li>
<ul>
</div>
<div class="footer-bottom">
<P>© 2015 Website by Andrew Hardiman</p>
</div>
【问题讨论】: