如何实现以下布局?

时间:2016-11-09 07:52:01

标签: html css

enter image description here

我并不太关心"内容"区域,更像是导航栏。我之前没有使用下拉菜单做过任何工作。此外我目前的尝试都失败了,我的汉堡包图标非常不合适,似乎它上面有某种无形的边缘。然后我的标题文字贴在导航栏的顶部。



a:link, a:hover, a:active, a:visited {
 	text-decoration: none;
 	color: inherit;
 }
 

div.nav {
	width: 100%;
	background-color: #1c1c1c;
	color: white;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	margin-top: 0;
	height: 50px;
}



.nav h1 {
	text-align: center;
	margin: 0 auto;
	font-size: 1.5em;
	position: fixed;
	top: 0;
	left: 50%;
	right: 50%;
}

.nav h2 {
	text-align: left;
	color: white;
	position: fixed;
	top: 0;
	left: 2%
}

li.dropdown {
	text-align: left;
}

div.dropdown-content {
	display: none;
}

	<div class="nav">
		<h1>Title</h1>
		<h2>☰</h2>

	</div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

做更多的研究。

a:link, a:hover, a:active, a:visited {
 	text-decoration: none;
 	color: inherit;
 }
 

div.nav {
	width: 100%;
	background-color: #1c1c1c;
	color: white;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	margin-top: 0;
	height: 50px;
}



.nav h1 {
	text-align: center;
	margin: 0 auto;
	font-size: 1.5em;
	position: fixed;
	top: 0;
	left: 50%;
	right: 50%;
}

.nav h2 {
	text-align: left;
	color: white;
	position: fixed;
	top: 0;
	left: 2%
}

li.dropdown {
	text-align: left;
}

div.dropdown-content {
	display: none;
}
.content{
  display: inline-block;
  width: 45%;
  height: 200px;
  border: 2px solid black;
  border-radius: 10px;
  margin: 60px 10px 0 10px;
  text-align: center;
}
	<div class="nav">
		<h1>Title</h1>
		<h2>☰</h2>

	</div>

    <div>
        <div class="content">
            content
         </div>
        <div class="content">
            content
         </div>
    </div>

答案 1 :(得分:0)

我在开发的这个阶段提供的最佳建议是,您将了解CSS重置。 http://sixrevisions.com/css/css-reset-stylesheets/解释得更多。通过将样式重置为“零”位置(在所有浏览器中),您可以以一定的一致性启动项目。

相关问题