三部分 附录(因为暂时不支持插入超链接所以部分内容无法显示)
附录一 DIV命名规范
附录二 CSS精灵
a { display:block; width:200px; height:65px; line-height:65px; /*定义状态*/ text-indent:-2015px; /*隐藏文字*/ background-image:url(button.png); /*定义背景图片*/ background-position:0 0; /*定义链接的普通状态,此时图像显示的是顶上的部分*/ } a:hover { background-position:0 -66px; /*定义链接的滑过状态,此时显示的为中间部分,向下取负值*/ } a:active { background-position:0 -132px; /*定 义链接的普通状态,此时显示的是底部的部分,向下取负值*/ }
附录三 一些tips解决方案
页面优化实践
写DIV+CSS 的一些常识
常用代码片段
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td { margin:0; padding:0; } body { background:#fff; color:#555; font-size:14px; font-family: Verdana, Arial, Helvetica, sans-serif; } td, th, caption { font-size:14px; } h1, h2, h3, h4, h5, h6 { font-weight:normal; font-size:100%; } address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal; } a { color:#555; text-decoration:none; } a:hover { text-decoration:underline; } img { border:none; } ol,ul,li { list-style:none; } input, textarea, select, button { font:14px Verdana,Helvetica,Arial,sans-serif; } table { border-collapse:collapse; } html { overflow-y: scroll; } .clearfix:after { content: "."; display: block; height:0; clear:both; visibility: hidden; } .clearfix { *zoom:1; }
<meta name=”viewport” content=”width=320,target-densitydpi=dpi_value,initial-scale=1, user-scalable=no”/>
table-layout: fixed; word-break: break-all;;border-collapse: collapse
<div id=”abc” style=”display:table;text-align:center;width:100%;height:100%;”> <span style=”background:#f00; display:table-cell; vertical-align:middle;”> <input type=”button” value=”item1″ /> </span> </div>
filter:alpha(opacity=50); /*1-100*/ -moz-opacity:0.5; /*0-1.0*/ -khtml-opacity:0.5; /*0-1.0*/ opacity:0.5; /*0-1.0*/
white-space:nowrap; text-overflow:ellipsis; overflow:hidden;
.fix{zoom:1;} .fix:after{ display:block; content:'clear'; clear:both; line-height:0; visibility:hidden; }
一些总结
一些概念
学习从来不是一个人的事情,要有个相互监督的伙伴,想要学习或交流前端问题的小伙伴可以私信“学习”小明加群获取2019web前端最新入门资料,一起学习,一起成长!
过CSS背景属性,可以给页面元素添加背景样式。
背景属性可设置背景颜色、背景图片、背景平铺、背景图片位置、背景图像固定等。
background-color:rgb值或颜色单词;
默认背景颜色值为transparent(透明)。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>背景属性</title>
<style>
div {
width: 300px;
height: 300px;
border: 1px solid;
}
/* 背景颜色 */
.bg-color {
background-color: transparent;
}
.bg-color-trans {
text-align: center;
background-color: pink;
width: 100px;
height: 100px;
line-height: 100px;
}
</style>
</head>
<body>
<div class="bg-color">背景颜色
<div class="bg-color-trans">透明背景</div>
</div>
</body>
</html>
效果:
Background-image:图片路径URL;
默认背景图片值为none。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>背景属性</title>
<style>
div {
width: 300px;
height: 300px;
border: 1px solid;
}
.bg-image {
background-image: url(../images/meitizhub.jpg);
}
</style>
</head>
<body>
<div class="bg-image">背景图片</div>
</body>
</html>
效果:
background-repeat:repeat | no-repeat | repeat-x | repeat-y
background-repeat:repeat;
默认情况下背景图片状态为平铺,指的是图片会从左向右且从上到下整个铺满盒子。
background-repeat:no-repeat;
关闭默认平铺状态,只在盒子左上角显示一个完整的背景图片。
background-repeat:repeat-x;
沿着x轴方向在盒子内最顶部横向平铺背景图片。
background-repeat:repeat-y;
沿着y轴方向在盒子内最左侧纵向平铺背景图片。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>背景属性</title>
<style>
div {
width: 300px;
height: 300px;
border: 1px solid;
}
.bg-repeat {
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div class="bg-image">背景平铺默认值</div>
<div class="bg-image bg-repeat">背景不平铺</div>
<div class="bg-image bg-repeatx">x轴方向平铺背景图片</div>
<div class="bg-image bg-repeaty">y轴方向平铺背景图片</div>
</body>
</html>
效果:
background-position:x y;
x轴和y轴的值可以是方位名词或者精确数值都可。
方位名词:top、bottom、center、left、right。
当属性值使用方位名词时如果只写一个值,则第二个值默认为居中状态。
当属性值使用精确数值时如果只写一个值,则默认是x轴方向的值,y轴方向默认垂直居中。
如果参数是方位词和精确单位混合使用时,默认第一个值是x值,第二个是y值。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>背景属性</title>
<style>
div {
width: 300px;
height: 300px;
border: 1px solid;
}
.bg-position {
background-repeat: no-repeat;
background-position: center top;
}
.bg-position2 {
background-repeat: no-repeat;
background-position: right;
}
.bg-position3 {
background-repeat: no-repeat;
background-position: 20px 50px;
}
.bg-position4 {
background-repeat: no-repeat;
background-position: 20px ;
}
.bg-position5 {
background-repeat: no-repeat;
background-position: 80px bottom ;
}
</style>
</head>
<body>
<div class="bg-image bg-position">背景图片存放位置1</div>
<div class="bg-image bg-position2">背景图片存放位置,设置一个值</div>
<div class="bg-image bg-position3">背景图片存放位置精确单位值</div>
<div class="bg-image bg-position4">背景图片存放位置精确单位值</div>
<div class="bg-image bg-position5">背景图片存放位置混合使用</div>
</body>
</html>
效果:
background-attachment:scroll | fixed;
背景图像在页面的某一处固定不动或者随页面的其余部分滚动。可以制作视差滚动效果。
background-attachment:scroll ;
默认值,背景图像固定在页面上,随着滚动条滚动而移动。
background-attachment:fixed;
背景图像固定在某一区域,滚动条滑动时位置不变。
body {
background-image: url(../images/43619545307190.png);
background-repeat: no-repeat;
background-position: center top;
background-attachment: fixed;
}
background:背景颜色、背景图片地址、背景平铺、背景图像滚动、背景图片位置;
没有特定书写顺序,按需使用属性。
实现背景颜色半透明效果。
background:rgb(0,0,0, 0.3);
最后一个参数是alpha透明度,取值范围在0~1之间。
总结:
属性 | 定义 | 值 |
Background-color | 背景颜色 | Rgb值 | 十六进制 | 颜色英文单词 |
Background-image | 背景图片 | Url(图片路径) |
Background-repeat | 背景平铺 | Repeat | no-repeat |repeat-x |repeat-y |
Background-position | 背景固定 | x轴和y轴。方向名词或者精确数值 |
Background-attachment | 背景附着 | Scroll(固定在页面上)| fixed(与滚动条固定) |
背景复合写法 | 代码简洁 | 背景颜色、图片地址、平铺、 滚动、位置。 |
背景颜色半透明 | 显示效果 | Background:rgba(0,0,0,0~1) |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
/*总体的样式*/
<style>
/*盒子样式*/
#box{
width: 350px; //宽
height: 450px; //高
border: 1px solid black; //边框
border-radius: 10px; //边框弧度
font-family: 黑体; //字体
letter-spacing:8px; //段间距
word-spacing: 10px; //字间距
line-height: 40px; //行高
font-size: 18px; //字大小
padding: 20px; //内边框
}
/*给'注册'赋予样式*/
.register{
width:280px ; //宽
height: 50px; //高
background-color: skyblue; //背景颜色
border-radius: 10px; //边框弧度
}
/*将所有边框都改变*/
*{
border-radius: 5px; 边框弧度
}
/*使用class选择器,赋予number宽高和边框*/
.number{
width: 185px; //宽
height: 27px; //高
border-width: 1px; //边框宽度
}
/*id选择器*/
#two{
width: 55px; //宽
border-width: 1px; 边框宽度
}
/*id选择器*/
#phone{
width: 103px; //宽
}
/*class 选择器*/
.boxs{
zoom: 75%; //清除浮动
color: darkgray; //颜色
}
/*class选择器*/
.box_a{
width: 50px; //宽
height: 50px; //高
background-image: url("../image/04.jpg "); //背景图片
background-repeat: no-repeat; // 是否平铺
background-size: 50px 25px; //背景尺寸
position: relative; //定位 相对定位
left: 310px; //定位后左移
bottom: 32px; //定位后下移
}
</style>
</head>
<body>
<div id="box">
<h1>请注册</h1>
<p style="color: darkgray">已有帐号?<a href="https://im.qq.com/index">登录</a></p>
<form action="" method="post">
<label for="name">用户名</label>
<input type="text" placeholder="请输入用户名" id="name" class="number"> <br>
<label for="phone">手机号</label>
<select name="" id="two" class="number">
<optgroup>
<option style="" class="">+86</option>
</optgroup>
</select>
<input type="text" placeholder="请输入手机号" id="phone" class="number"> <br>
<label for="mima">密 码</label>
<input type="password" placeholder="请输入密码" id="mima" class="number"> <br>
<label for="mima">验证码</label>
<input type="password" placeholder="请输入验证码" id="is" class="number">
<div class="box_a"></div>
<div class="boxs">
<input type="radio" id="" class="accept">阅读并接受协议<br>
</div>
<input type="submit" value="注册" class="register" >
</form>
</div>
</body>
</html>
在这里插入图片描述
*请认真填写需求信息,我们会在24小时内与您取得联系。