HTML5+CSS3设计页面布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
<style>
@charset "utf-8";
/* CSS Document */
body {
background-color: #cccccc;
font-family: Geneva, sans-serif;
margin: 10px auto;
max-width: 800px;
border: solid;
border-color: #ffffff;
}
h2 {
text-align: center;
}
header {
background-color: #f47d31;
color: #ffffff;
text-align: center;
}
article {
background-color: #eeeeee;
}
p {
color: #ff3366;
}
nav,
article,
aside {
margin: 10px;
padding: 10px;
display: block;
}
header#page_header nav {
list-style: none;
margin: 0;
padding: 0;
}
header#page_header nav ul li {
padding: 0;
margin: 0 20px 0 0;
display: inline;
}
section#posts {
display: block;
float: left;
width: 70%;
height: auto;
background-color: #ff6699;
}
section#posts aside {
background-color: #006699;
display: block;
float: right;
width: 35%;
margin-left: 5%;
font-size: 20px;
line-height: 40px;
}
section#posts article footer {
background-color: #003399;
clear: both;
height: 50px;
display: block;
color: #ffffff;
text-align: center;
padding: 15px;
}
section#sidebar {
background-color: #eeeeee;
display: block;
float: right;
width: 25%;
height: auto;
background-color: #669999;
margin-right: 15px;
}
footer#page_footer {
display: block;
clear: both;
width: 100%;
margin-top: 15px;
display: block;
color: #ffffff;
text-align: center;
background-color: #0066cc;
}
</style>
</head>
<body>
<h2>body</h2>
<header id="page_header">
<h1>Header</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
</ul>
</nav>
</header>
<section id="posts">
<h2>Section</h2>
<article class="post">
<h2>article</h2>
<header>
<h2>Article Header</h2>
</header>
<aside>
<h2>Article Aside</h2>
</aside>
<p>Without you?I'd be a soul without a purpose.</p>
<footer>
<h2>Article Footer</h2>
</footer>
</article>
<article class="post">
<h2>article</h2>
<header>
<h2>Article Header</h2>
</header>
<aside>
<h2>Article Aside</h2>
</aside>
<p>Without you?I'd be a soul without a purpose.</p>
<footer>
<h2>Article Footer</h2>
</footer>
</article>
</section>
<section id="sidebar">
<h2>Section</h2>
<header>
<h2>Sidebar Header</h2>
</header>
<nav>
<h3></h3>
<ul>
<li><a href="#">April 2019</a></li>
<li><a href="#">March 2019</a></li>
<li><a href="#">February 2019</a></li>
<li><a href="#">January 2019</a></li>
</ul>
</nav>
</section>
<footer id="page_footer">
<h2>Footer</h2>
</footer>
</body>
</html>
设计漂亮的导航菜单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
<style>
ul, li {
list-style: none;
margin: 0;
padding: 0;
}
a {
color: #9a9a9a;
text-decoration: none;
}
.demo1 li {
background-color: rgba(238, 238, 238, 1);
-webkit-transition: all 0.3s ease-in-out 0s;
-moz-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
padding-left: 1%;
height: 50px;
min-height: 50px;
width: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
}
.demo1 li a {
width: 50%;
height: 50px;
line-height: 50px;
padding-left: 5px;
position: absolute;
}
.demo1 li:hover {
background-color: rgba(238, 238, 238, 1);
-webkit-transition: all 0.3s ease-in-out 0s;
-moz-transition: all 0.3s ease-in-out 0s;
-o-transition: all 0.3s ease-in-out 0s;
-ms-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
width: 50%;
}
</style>
</head>
<body>
<ul class="demo1">
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
<script>
</script>
</body>
</html>
设计登录界面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
<style>
body {
font: 12px 'Lucida Sans Unicode', 'Trebuchet MS', Arial, Helvetica;
margin: 0;
background-color: #d9dee2;
}
#login {
background-color: #ffffff;
height: 240px;
width: 400px;
margin: -150px 0 0 -230px;
padding: 30px;
position: absolute;
top: 50%;
left: 50%;
z-index: 0;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, 0.2),
0 3px 0 #ffffff,
0 4px 0 rgba(0, 0, 0, 0.2),
0 6px 0 #ffffff,
0 7px 0 rgba(0, 0, 0, 0.2);
-moz-box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, 0.2),
0 3px 0 #ffffff,
0 4px 0 rgba(0, 0, 0, 0.2),
0 6px 0 #ffffff,
0 7px 0 rgba(0, 0, 0, 0.2);
box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, 0.2),
0 3px 0 #ffffff,
0 4px 0 rgba(0, 0, 0, 0.2),
0 6px 0 #ffffff,
0 7px 0 rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<form id="login">
<h1>登录</h1>
<fieldset id="inputs">
<input id="username" type="text" placeholder="用户名" autofocus required>
<input id="password" type="text" placeholder="密码" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="登录">
<a href="">忘记密码?</a>
<a href="">注册新用户</a>
</fieldset>
</form>
<script>
</script>
</body>
</html>
再继续优化标题、文本框和按钮的样式。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Test</title>
<style>
body {
font: 12px 'Lucida Sans Unicode', 'Trebuchet MS', Arial, Helvetica;
margin: 0;
background-color: #d9dee2;
}
#login {
background-color: #ffffff;
height: 240px;
width: 400px;
margin: -150px 0 0 -230px;
padding: 30px;
position: absolute;
top: 50%;
left: 50%;
z-index: 0;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, 0.2),
0 3px 0 #ffffff,
0 4px 0 rgba(0, 0, 0, 0.2),
0 6px 0 #ffffff,
0 7px 0 rgba(0, 0, 0, 0.2);
-moz-box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, 0.2),
0 3px 0 #ffffff,
0 4px 0 rgba(0, 0, 0, 0.2),
0 6px 0 #ffffff,
0 7px 0 rgba(0, 0, 0, 0.2);
box-shadow:
0 0 2px rgba(0, 0, 0, 0.2),
0 1px 1px rgba(0, 0, 0, 0.2),
0 3px 0 #ffffff,
0 4px 0 rgba(0, 0, 0, 0.2),
0 6px 0 #ffffff,
0 7px 0 rgba(0, 0, 0, 0.2);
}
fieldset {
border: 0;
padding: 0;
margin: 0;
}
#inputs input {
padding: 15px 15px 15px 30px;
margin: 0 0 10px 0;
width: 353px;
border: 1px solid #cccccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow:
0 1px 1px #cccccc inset,
0 1px 0 #fff;
-webkit-box-shaow:
0 1px 1px #cccccc inset,
0 1px 0 #fff;
box-shadow:
0 1px 1px #cccccc inset,
0 1px 0 #fff;
}
#inputs input:focus {
background-color: #ffffff;
border-color: #e8c291;
outline: none;
-moz-box-shadow: 0 0 0 1px #e8c291 inset;
-webkit-box-shadow: 0 0 0 1px #e8c291 inset;
box-shadow: 0 0 0 1px #e8c291 inset;
}
#actions {
margin: 25px 0 0 0;
}
#submit {
background-color: #ffb94b;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
-moz-box-shadow:
0 0 1px rgba(0, 0, 0, 0.3),
0 1px 0 rgba(255, 255, 255, 0.3) inset;
-webkit-box-shadow:
0 0 1px rgba(0, 0, 0, 0.3),
0 1px 0 rgba(255, 255, 255, 0.3) inset;
box-shadow:
0 0 1px rgba(0, 0, 0, 0.3),
0 1px 0 rgba(255, 255, 255, 0.3) inset;
border-width: 1px;
border-style: solid;
border-color: #d69e31 #e3a037 #d5982d #e3a037;
float: left;
height: 35px;
padding: 0;
width: 120px;
cursor: pointer;
font: bold 15px Arial, Helvetica;
color: #8f5a0a;
}
#actions a {
color: #3151a2;
float: right;
line-height: 35px;
margin-left: 10px;
}
</style>
</head>
<body>
<form id="login">
<h1>登录</h1>
<fieldset id="inputs">
<input id="username" type="text" placeholder="用户名" autofocus required>
<input id="password" type="text" placeholder="密码" required>
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="登录">
<a href="">忘记密码?</a>
<a href="">注册新用户</a>
</fieldset>
</form>
<script>
</script>
</body>
</html>