大家好,又见面了,我是你们的朋友全栈君。
页面布局整体思路:
效果图如下:
导航栏注意点:
把CSS布局页面引入HTML中,代码如下
<link rel="stylesheet" href="style.css">
确定版心
页面的版心是1200px,每个版心都要水平居中对齐,可以定义版心为公共类:
.w{
width:1200px;
margin:auto;
}
index.html
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header w">
<!-- 标志模块 -->
<div class="logo">
<img src="images/logo.png">
</div>
<!-- 文字导航栏模块 -->
<div class="nav">
<ul>
<li>
<a href="#">首页</a>
</li>
<li>
<a href="#">课程</a>
</li>
<li>
<a href="#">职业规划</a>
</li>
</ul>
</div>
<!-- 搜索模块 -->
<div class="search">
<input type="text" value="输入关键词" ></input>
<button></button>
</div>
<!-- 用户模块 -->
<div class="user">
<img src="images/user.png" style="vertical-align: middle">
qq-lilei
</div>
</div>
</body>
style.css
*{
margin: 0;
padding: 0;
}
.w{
width:1200px;
margin: auto;
}
li{
list-style: none;
}
a{
text-decroation: none;
}
.header{
height: 42px;
margin:30px auto;
}
.logo{
float: left;
width: 198px;
height: 42px;
}
.nav{
float: left;
margin-left: 60px;
}
.nav ul li{
float: left;
margin: 0 15px;
}
.nave ul li a{
display: block;
height: 42px;
padding: 0 10px;
line-height: 42px;
color: black;
}
.nave ul li a: hover{
border-bottom: 2px solid #00a4ff;
}
.search{
float: left;
width: 412px;
height: 42px;
background-color: #00a4ff;
margin-left: 50px;
}
.search input{
float: left;
width: 345px;
height: 40px;
border: 1px solid #00a4ff;
border-right: 0;
color: #bfbfbf;
font-size: 14px;
padding-left: 15px;
}
.search button{
float: left;
width: 50px;
height: 42px;
/* 去掉按钮默认边框 */
border: 0;
background: url(images/btn.png);
.user{
float: left;
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/140268.html原文链接:https://javaforall.cn