<!--整体架构,因为要整幅居中,所以需要本容器-->
<div class="wrapper">
<!--页面头部,包括logo、菜单、介绍三个部分-->
<header></header>
<!--页面中间,包括兴趣、项目、联系三个部分-->
<main></main>
<!--页面脚部,包括版权和向上跳转部分-->
<footer></footer>
</div>
<!--整体架构,因为要整幅居中,所以需要本容器-->
<div class="wrapper">
<!--页面头部,包括logo、菜单、介绍三个部分-->
<header>
<a href="index.html" class="logo">
<h1>个人主页</h1>
<img src="img/steemit.svg" alt="" />
</a>
<div class="mainNav">
<ul class="clearfix">
<li><a href="#a">关于</a></li>
<li><a href="#b">工作</a></li>
<li><a href="#c">联系</a></li>
</ul>
</div>
<a id="a"></a>
<h2>大家好,我是王海庆。</h2>
<p>我是一个前端迷,喜欢探索,喜欢研究,对一切未知而又充满质感的事物充满好奇心,永远保持一颗童心。</p>
<p>浙江邮电职业技术学院青年教师一枚,执着于前端技术。html5、css3、javascript、jquery、vue.js、angularjs、babel、sass、markdown、git等等都是我的最爱!!</p>
<p>来吧,让我们一起来畅游前端的世界。<a href="http://codepen.io/ericthayer/pen/zNxMer">模仿实现</a>,但适度创意!!</p>
</header>
<!--页面中间,包括兴趣、项目、联系三个部分-->
<main></main>
<!--页面脚部,包括版权和向上跳转部分-->
<footer></footer>
</div>
/*
公共设置
* */
*{
box-sizing: border-box;
}
.clearfix::after{
content: "";
display: table;
clear: both;
}
ul{
padding: 0;
list-style-type: none;
}
a{
text-decoration: none;
color: #fff;
}
/*
整体设置
* */
body{
background: url(../img/bg.jpg) center top fixed;
min-height: 1200px;
color: #fff;
}
.wrapper{
max-width: 1200px;
padding: 20px;
margin: auto;
}
/*
头部设置
* */
header{
position: relative;
margin: 30px 0px;
}
.logo h1{
display: none;
}
.logo img{
width: 80px;
height: auto;
}
.mainNav{
position: absolute;
top: 0;
right: 0;
}
.mainNav ul li{
float: left;
margin: 20px 30px;
}
.mainNav ul li a{
text-decoration: none;
color: #fff;
padding: 20px;
border: 1px solid transparent;
transition: color .5s,border .5s;
//这里注意,最好不用设置成 all .5s
}
.mainNav ul li a:hover{
color: #000;
border: 1px solid #fff;
}
header h2{
margin: 50px 0;
font-size: 30px;
}
p a{
border-bottom:1px dashed #fff;
padding-bottom: 4px;
transition: border .5s;
}
p a:hover{
border-bottom:1px solid #fff;
}
<main>
<section class="favContainer">
<h2>我的兴趣</h2>
<ul class="fav clearfix">
<li><a href="#" title="响应式布局">RWD</a></li>
<li><a href="#" title="流体布局">Flexbox</a></li>
<li><a href="#" title="CSS的预处理器">Sass</a></li>
<li><a href="#" title="CSS的预处理">Less</a></li>
<li><a href="#" title="CSS前缀处理">Autoprefix</a></li>
<li><a href="#" title="CSS新式布局方式">Grid</a></li>
<li><a href="#" title="不错的鼠标悬停效果集">iHover</a></li>
<li><a href="#" title="不错的动画库">Animate.css</a></li>
</ul>
</section>
</main>
/*
* 中间部分设置
* */
main section{
margin: 50px 0px;
}
main section h2{
margin-bottom: 0px;
}
.fav li{
float: left;
width: 160px;
height: 48px;
text-align: center;
line-height: 48px;
background-color:rgba(100,100,200,.6);
margin: 10px 20px 0px 0px;
cursor: pointer;
border-radius: 5px;
transition: background .5s,border-radius .5s;
}
.fav li:hover{
border-radius: 0px;
background-color:rgba(100,100,200,.8);
}
<section class="workContainer">
<a id="b"></a>
<h2>项目示例</h2>
<div class="work clearfix">
<figure>
<figcaption>代表项目</figcaption>
<img src="img/office.jpg" alt="" />
</figure>
<figure>
<figcaption>代表项目</figcaption>
<img src="img/office.jpg" alt="" />
</figure>
<figure>
<figcaption>代表项目</figcaption>
<img src="img/office.jpg" alt="" />
</figure>
<figure>
<figcaption>代表项目</figcaption>
<img src="img/office.jpg" alt="" />
</figure>
<figure>
<figcaption>代表项目</figcaption>
<img src="img/office.jpg" alt="" />
</figure>
<figure>
<figcaption>代表项目</figcaption>
<img src="img/office.jpg" alt="" />
</figure>
</div>
</section>
.work{
padding: 0;
margin: 0;
}
.work figure{
width: 30%;
margin: calc(10% / 6) calc(10% / 2) 0 0;
float: left;
position: relative;
}
.work figure:nth-child(3n){
margin-right: 0px;
}
.work figure figcaption{
width: 100%;
height: 30px;
position: absolute;
z-index: 3;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
text-align: center;
opacity: 0;
transition: opacity .5s;
}
.work figure:hover figcaption{
opacity: 1;
}
.work figure img{
width: 100%;
height: auto;
-webkit-filter: grayscale(.5);
transition: webkit-filter .5s;
cursor: pointer;
}
.work figure:hover img{
-webkit-filter: grayscale(0);
}
<section class="contactContainer">
<a id="c"></a>
<h2>联系我们</h2>
<p>前端技术发展非常迅速,个人视野有限,希望大家可以通过广泛的交流互动,实现共同提高!!期待您的回复!!</p>
<dl>
<dt>邮箱</dt>
<dd>whqet@qq.com</dd>
<dt>QQ</dt>
<dd>86079959</dd>
</dl>
<div class="contact">
<input type="text" name="name" id="name" placeholder="名字" />
<input type="text" name="name" id="name" placeholder="邮箱" />
<select name="fav" id="fav">
<option value="fav">兴趣</option>
<option value="web">网页开发</option>
<option value="app">应用开发</option>
<option value="html5">html5开发</option>
<option value="chat">微信开发</option>
</select>
<textarea name="message" id="message" placeholder="留言"></textarea>
<input type="submit" name="submit" id="submit" value="提交信息"/>
</div>
</section>
/*
contact 部分
* */
.contactContainer dl dt{
padding:5px 20px;
background-color: #fff;
color: #000;
display: inline-block;
}
.contactContainer dl dd{
padding:5px 20px;
background-color: #000;
color: #fff;
margin: 0px 30px 0px 0px;
display: inline-block;
}
.contact input{
width: 31%;
margin: 5px 2% 5px 0px;
padding: 10px 16px;
border-radius: 3px;
border: none;
outline: none;
}
.contact select{
width: 32%;
padding: 10px 16px;
border-radius: 3px;
margin: 5px 0px 5px 4px;
}
.contact textarea,
.contact input[type="submit"]{
width: 48%;
height: 50px;
padding: 10px 16px;
border-radius: 3px;
margin: 5px 3% 5px 0px;
vertical-align: top;
}
.contact input[type="submit"]{
margin: 5px 0px;
border:none;
outline: none;
background-color: #00BFFF;
cursor: pointer;
}
<footer>
<p>
© 王海庆版权所有,如有雷同,非常感谢!
</p>
<a id="goTop" href="#">顶部</a>
</footer>
/*
版权部分
* */
#goTop{
position: fixed;
right: 20px;
bottom: 20px;
border: 1px solid #fff;
width: 40px;
height: 40px;
text-align: center;
line-height: 40px;
font-size: 0.8em;
color: #fff;
}
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('header a').on('click', function(e) {
e.preventDefault();
$('html, body').animate({ scrollTop: $($(this).attr('href')).offset().top}, 500);
});
$('#goTop').on('click', function(e) {
e.preventDefault();
$('html, body').animate({ scrollTop: 0}, 500);
});
});
</script>
/**
* CSS书写顺序
* 先全局,再局部
* 先抽象,再具体
* 先上面,后下面
* hover前后紧挨着(行为处理前后选择器最好保持统一)
*/
/**
* CSS属性的使用-不知道写那些属性时考虑
* 显示方式,display为none、block、inline-block
* 宽高大小
* 颜色、背景, color,background
* 内外边距、边框、圆角,padding margin border border-radius
* 位置 float position left right top bottom
* 对齐方式 text-align vertical-align line-height
* 阴影 box-shadow
* 过渡 transition
* 等等
*/
/*
* 某文本元素需要居中,父元素里设置text-align:center
* 某块元素水平居中,固定宽度,水平方向margin为auto
* 单行文本垂直居中,设置行高=高度或设置上下相同的padding值
*/
.center1{
width:400px;
height:400px;
position:absolute;
left:50%;
top:50%;
margin-top:-200px;
margin-left:-200px;
}
.center2{
width:400px;
height:400px;
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
margin:auto;
}
/*
* 如果不用浮动、定位就可以实现效果,尽量不用浮动、定位
* 如果有多个元素同时需要脱离常规流,同时没有上下位置的区别,用浮动。
* 如果某个元素相对于某层父元素位置固定,用(绝对)定位。
*/
/*
* 如果浮动,一定清除
* 一般在产生浮动的父元素上,使用clearfix类清除浮动。
*/
.clearfix::after{
content:"";
display:table;
clear:both;
/*也可以设置些隐藏内容的属性*/
}
/**
* 距离的设置
* padding和margin的使用
* 具体使用,结合背景、边框而定。
*/