前端开发之css


























<!--
页面中的组成部分
通常随便打开一个网页,有文字,图片,视频,表格,音频,表单(注册信息)

css 属性/尺寸/边框/背景

1.css的尺寸属性,就是大小
width max-width min-width
height max-height min-height

2.css的边框属性
border-style 边框风格
none:无边框。 border-color和boder-width都将被忽略
hidden:隐藏边框。
dotted:点状边框。
dashed:虚线边框。
solid:实线边框。
double:双线边框。两条单线与其间隔的和等于指定的border-width的值。
groove:3D凹槽轮廓。
ridge:3D凸槽轮廓。
inset:3D凹边轮廓。
outset:3D凸边轮廓。

border-color 边框颜色
border-width 边框宽度


3.内边距属性
padding-left: 20px; 左边距
padding-top: 50px; 上边距
padding-right: 100px;右边距
padding-bottom: 150px;下边距

/*复合属性*/
padding: 值; 上下左右

/*padding: 20px;*/
/*padding: 20px 40px;*/ 上下 左右
/*padding: 20px 40px 60px;*/ 上 左右 下
padding: 10px 20px 30px 40px; 上 右 下 左


4.css背景属性



-->




<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>张仁国杨静结婚啦</title>
<style type="text/css">
.item {
/*设置元素的宽高*/
/* 300px;*/
/*max- 300px;*/
/*min- 300px;*/
600px;
/*height: 400px;*/
/**/

/*border 边框*/

border-style: solid;
border-color: #f90;
border- 1px;

/*复合属性*/
/*border: 2px solid red;*/



/*内边距 padding*/
padding-left: 20px;
padding-top: 50px;
padding-right: 100px;
padding-bottom: 150px;

/*复合属性*/
/*padding: 20px;*/
/*padding: 20px 40px;*/
/*padding: 20px 40px 60px;*/
padding: 10px 20px 30px 40px;


}

</style>
</head>
<body>
<h1>CSS的尺寸属性 边框属性 内边距</h1>
<hr>


<div class="item">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid aperiam consectetur corporis dolorum, earum eos et explicabo fuga harum id itaque maiores nam nobis possimus quasi ratione suscipit totam vitae?
</div>

</body>
</html>




css背景里面精灵图.html

<!--
css sprite 精灵图 雪碧图

利用backgroundposition 设置背景图片的位置

把很多小的图片 集成到一张大图上

好处:减少网络请求数量


-->









<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>精灵图</title>
<style type="text/css">
button {
122px;
height: 30px;
border: 1px solid #c1c1c1;

background-image: url("../xxx.png");
background-repeat: no-repeat;
background-position: -1px -2px;

/*background: url("") no-repeat -30px -30px;*/

}

a {
;
height: ;
background: url("") no-repeat -40px -30px;

}

</style>
</head>
<body>
<h1>CSS 精灵图知识</h1>
<hr>

<!--<button>ok</button>-->
<!--按钮-->
<button></button>
<br>
<a href="http://www.qq.com"></a>
</body>
</html>


背景

<!--
背景属性
1.背景颜色


背景图片
background-image: url("写地址");
如果元素比较大图片比较小,就会平铺

背景图片平铺设置
background-repeat: repeat; 默认值就是repeat表示平铺
可以设置为不平铺,不平铺剩下的默认为背景色
background-repeat: no-repeat;
水平平铺
background-repeat: repeat-x;
竖着平铺
background-repeat: repeat-y;


首先设置为不平铺,因为都铺满了还谈什么位置。
background-postion: 水平方向的位置 垂直方向的位置

background-postion: left top;
background-postion: left center;
background-postion: center center;

建议先写颜色,图片,repeat,postion。
background-postion: 10px 10px; (距离左边10像素 距离右边10像素)

背景图片固定
background-attachment: fixed;



复合属性
background:#ccc url('') no-repeat 10px 10px;
-->






<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>同志约会</title>
<style type="text/css">
.item {
600px;
height: 200px;
border: solid #f90 2px;

background-color: #cccccc;


/*background-image: url("写地址");*/


}

</style>
</head>
<body>
<h1>背景属性</h1>
<hr>
<div class="item"></div>

</body>
</html>



超链接与锚点

<!--
<a href="要跳转的地址">超链接文字</a>

在新的个窗口打开
<a href="要跳转的地址" target=“_blank”>超链接文字</a>

title 鼠标放上面会显示

<a href="要跳转的地址" target=“_blank” title=“描述文字”>超链接文字</a>


还可以是图片,浏览器可以直接打开图片

下载图片加个download属性就可以了


超级链接
a元素
属性
href
target _blank /_self
title
download H5新增的

特殊方法
跳转网页
发短信
打电话
发邮件

相对路径 ./ ../
绝对路径 url 统一资源定位符,定位的是一个文件在网络上的地址,HTML,JPG,GIF。。。

统称url

特殊的相对路径 /开始的路径 表示的的网站的根目录





鼠标属性

pointer/move/no-drop



锚点
设置锚点
第一种方式:
<a name="锚点名字”></a>
第二种方式:
任意一个元素
<tagname id="锚点的名字"></tagname>

跳转到指定锚点:
<a href="#锚点名”></a>


完整URL
http://www.baidu.com/paht/demo/contents/index.php?a=100&b=300#mao1

协议protocol http
主机名(可以是域名也可以是ip)hostname www.baidu.com
路径 path /paht/demo/contents/
文件filename index.php
查询内容query ?a=100&b=300
锚点 #mao1




-->




<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>张仁国跟杨静</title>
<style type="text/css">
h2 {
cursor: pointer;
cursor: move;
}


</style>
</head>
<body>
<h1>超链接</h1>
<!--锚点-->
<a href="#xiangzhi">他们相识</a>
<a href="#aiqing">他们相知</a>
<a href="#aiqing">他们相爱</a>
<a href="#幸福">他们幸福</a>
<a href="#很好">他们很好</a>
<a href="#快乐">他们快乐</a>
<hr>

<a href="http://www.taobao.com">淘宝</a> <br>
<a href="http://www.jd.com" target="_blank" >京东</a> <br>
<a href="http://www.xiaomi.com" target="_blank" title="小米">小米</a> <br>
<hr>

<h2>鼠标属性</h2>


<!--添加锚点-->
<a name="xiangzhi"></a>
<div style="height: 600px">
<h2>他们相识</h2>

</div>

<a name="aiqing"></a>
<div style="height: 600px">
<h2>他们相知</h2>
</div>

<div style="height: 600px" id="aiqing">
<h2>他们相爱</h2>
</div>

<div style="height: 600px">
<h2>他们结婚</h2>
</div>

<div style="height: 600px">
<h2>他们生子</h2>
</div>

<div style="height: 600px" id="幸福">
<h2>他们幸福</h2>
</div>

<div style="height: 600px" id="快乐">
<h2>他们快乐</h2>
</div>

<div style="height: 600px" id="很好">
<h2>他们很好</h2>
</div>


<a href="#">返回顶部</a>


</body>
</html>


原文地址:https://www.cnblogs.com/zhangrenguo/p/10080934.html