簡要仿簡書頭部純css與佈局

在這裏插入圖片描述
佈局

<!DOCTYPE html>
<html>
<head>
	<title>簡書</title>
</head>
<body>
<div class="contain">
	<div class="head">
		<a href="/" class="logo-index"></a>
		<ul class="list-ul">
			<li > <a href="/">發現</a></li>
			<li > <a href="/">關注</a></li>
			<li > <a href="/">消息</a></li>	
			<div class="search">
				<input type="" placeholder="搜索" class="search-input"/>
				<img src="" class="search-logo">
			</div>
		</ul>
		<div class="user">
			<img src="./static/avatar.jpg"/> 
			<ul class="dropdown-menu">
				<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>
			</ul>
		</div>
		
		<a href="/" class="button-write">
			<img src="" class="button-write-logo">
		寫文章</a>
		</div>
		
	</div>
</div>
<style type="text/css">
	html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}

body{
	margin: 0;
	padding:0 ;
}


a{
		text-decoration:none;
		color: #0a0a0a;
		cursor: pointer;
	}
	.head{
		position: relative;
		min-width: 768px;
		max-width: 1440px;
		background-color: #fff;
		height: 56px;
		border-bottom: 1px solid #f0f0f0;
	}
	.logo-index{
		background: url(static/nav-logo.png);
		position: absolute;
		top: 0;
		left: 0;
		display: block;
		width: 100px;
		height: 56px;
		/**
		圖片同比縮放在容器中
		*/
		background-size: contain;
	}

	.list-ul{
		display: flex;
		margin-left: 100px;
		width: 400px;
		height: 56px;
		float: left;
		vertical-align:middle;

	}

	.list-ul li{
		display: flex;
		width: 50px;
		height: 56px;
		justify-content: center;
		align-items: center;
	}

	.list-ul a{
		color: #0a0a0a;
		font-weight:700;
		font-family: sans-serif;
	}
	.list-ul li:hover{
		background-color: #eee;
	}

	.search {
		display: flex; 
		float: left;
		align-items: center;
	} 

	.search input{
		margin-left: 12px;
		width: 110px;
		height: 38px;
		padding: 0 40px 0 20px;
		border-radius: 40px;
		border:1px solid #eee;
		outline: none;
		background-color: #eee;
		transition:all 0.5s ease;
	}

	.search input:focus{
		width: 138px;
		transition:all 0.5s ease;
	}

	.user{
		display: inline-block;
		width: 80px;
		height: 48px;
		padding-top: 8px;
		position: absolute;
		right: 120px;
		text-align: center;
		cursor: pointer;
	}


	.user:hover .dropdown-menu {
		display: block;
	}
	.user:hover{
		background-color: #eee;	
	}



	.user img{
		width: 40px;
		height: 40px;
		border-radius: 50% 50%;
		border:1px solid #eee;
	}

	.button-write{
		display: inline-block;
		height: 40px;
		width:100px;
		text-align: center;
		background-color: #ea6f5a;
		color: #fff;
		border-radius: 20px;
		margin:8px 12px 0 12px; 
		line-height: 34px;
		float: right;
		font-size: 15px;
		opacity: 0.9;
	}

	.button-write:hover{
		opacity: 1
	}



	.dropdown-menu{
		display: none;
		background-color: #fff;	
		margin-top: 4px;
		box-shadow: 0 0 10px #ddd;
		width: 120px
	}


	.dropdown-menu li{
		font-family: sans-serif;
		font-weight: 700;
		padding: 10px;
		display: box;
		box-align:center;
		vertical-align: center;
	}

	.dropdown-menu li:hover{
		background-color: #ddd;
	}



</style>

</body>
</html>

實現了基本的動畫 純初級入門

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章