效果圖
html頁面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模擬百度一下</title>
<link rel="stylesheet" type="text/less" href="style/index.less">
<script src="js/less.min.js"></script>
</head>
<body>
<div class="header">
<ul class="header_nav">
<li><a href="###">新聞</a></li>
<li><a href="###">hao123</a></li>
<li><a href="###">地圖</a></li>
<li><a href="###">視頻</a></li>
<li><a href="###">貼吧</a></li>
<li><a href="###">學術</a></li>
<li><a href="###">登陸</a></li>
<li><a href="###">設置</a></li>
<li class="nav-more"><a href="###">更多產品</a></li>
</ul>
<div class="content">
<img src="image/bd_logo.png" alt="">
<div class="con-input">
<span></span>
<input type="text" class="search"><input type="button" class="btn" value="百度一下">
</div>
</div>
</div>
</body>
</html>
less樣式部分
*{
margin: 0;
padding: 0;
font-family:'微軟雅黑';
}
@color-blue: #398bfb;
.header{
width: 1000px;//給定寬度,就不會隨窗口大寫而改變
height: 40px;
line-height: 40px;
margin: 0 auto;
vertical-align: middle;
.header_nav{ //導航欄部分
float: right;
li{
list-style: none;
float: left;
margin-right: 10px;
font-size: 16px;
font-weight:bold;
a{
color:black;
}
}
.nav-more{ //更多產品樣式的重寫
width: 86px;
height: 32px;
font-size: 13px;
line-height: 32px;
text-align: center;
background: @color-blue;
a{
text-decoration: none;
color: #ffffff;
}
}
}
.content{ //中間搜索區域部分
position: relative;
clear: both;
height: 62%;
min-height: 181px;
margin-top: 100px;
text-align: center;
img{ //logo部分
width: 270px;
height: 129px;
}
.con-input{ //input框
margin-left: 20%;
position: absolute;
.search{
width: 521px;
height: 20px;
padding: 7px;
vertical-align: middle;
}
.btn{ //百度一下按鈕
width: 102px;
height: 38px;
background: @color-blue;
text-align: center;
line-height: 38px;
color: #ffffff;
font-size: 16px;
font-weight: normal;
cursor: pointer;
border: none;
vertical-align: middle;
}
span { //相機部分
background: url("../image/camera_new_5606e8f.png");
background-position: 0 0;
height: 18px;
width: 18px;
display: inline-block;
zoom: 1;
vertical-align: top;
position: absolute;
top: 14px;
right: 112px;
&:hover {
background-position: 0 -18px;
}
}
}
}
}