- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>选择器续</title>
- <style type="text/css">
- /* 子孙后代选择器 */
- body div div p{
- color: #FFA500;
- }
- /* 子元素选择器 */
- body>div>div>p{
- color: #7FFF00;
- }
- /* 伪类选择器 选择元素状态,必须按照一下顺序写 */
- a:link{/* 为访问 */
- color: pink;
- }
- a:visited{/* 访问过 */
- color: green;
- }
- a:hover{/* 悬停 */
- color: red;
- }
- a:active{/* 激活/点击状态 */
- color: yellow;
- }
- </style>
- </head>
- <body>
- <a href="../day01/03图片标签.html">超链接1</a>
- <a href="../day01/04超链接.html">超链接2</a>
- <a href="../day01/05表格标签.html">超链接3</a>
- <p>p1</p>
- <div><p>p2</p></div>
- <div>
- <div>
- <p>p3</p>
- </div>
- <div>
- <p>p4</p>
- <div>
- <p>p5</p>
- </div>
- </div>
- </div>
- </body>
- </html>
悬停黄色,点击粉色
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>选择器练习</title>
- <style type="text/css">
- #i-1{
- color: #7FFF00;
- }
- .c1{
- color: yellow;
- }
-
- input[type='text'],body>p{
- background-color: #FF0000;
- }
- body>div>div>p{
- color: #FFC0CB;
- }
- div>div>p{
- background-color: #FFFF00;
- }
- a:link{
- color: #7FFF00;
- }
- a:visited{
- color: #FF0000;
- }
- a:hover{
- color: #FFFF00;
- }
- a:active{
- color: #FFC0CB;
- }
- </style>
- </head>
- <body>
- <ul>
- <li>刘备</li>
- <li id="i-1">关羽</li>
- <li class="c1">张飞</li>
- </ul>
- <p>香蕉</p>
- <p class="c1">苹果</p>
- <input type="text">
- <input type="password">
- <div>
- <p>p1</p>
- <div>
- <p>p2</p>
- </div>
- <div>
- <div>
- <p>p3</p>
- </div>
- </div>
- </div>
- <a href="http://www.tedu.cn">达内官网</a>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>颜色和背景</title>
- <style type="text/css">
- h1{
- color: rgba(255,0,0,0.3);
- }
- div{
- width: 200px;
- height: 200px;
- background-color: purple;
- /* 设置背景图片 */
- background-image: url(../b.jpg);
- /* 设置图片尺度大小 */
- background-size: 100px;
- /* 禁止重复 */
- background-repeat: no-repeat;
- /* 控制背景图片的位置: 横向和纵向 */
- background-position: 30px 60px;
- }
- #d1{
- width: 611px;
- height: 376px;
- background-color: #e8e8e8;
- background-image: url(study_computer_img1.png);
- background-size: 318px 319px;
- background-position: 90% 90%;
- }
- #d2{
- width: 375px;
- height: 376px;
- background-color: #e8e8e8;
- background-image: url(study_computer_img2.png);
- background-size: 292px 232px;
- background-position: 90% 90%;
- }
- </style>
- </head>
- <body>
- <div id="d2">
-
- </div>
- <br>
- <div id="d1">
-
- </div>
- <div></div>
- <h1>颜色测试</h1>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>文本和字体</title>
- <style type="text/css">
- div{
- width: 200px;
- height: 50px;
- border: 1px solid red;
- /* 文本对其方式 */
- text-align: center;
- /* 文本修饰 overline 上划线,underline 下划线 line-through 删除线 none 没有线*/
- text-decoration: line-through;
- /* 设置行高,多行文本控制行距,单行文本控制垂直剧中 */
- line-height: 50px;
- /* 文本阴影:颜色 x偏移值 y偏移值 浓度 */
- text-shadow: red -10px 10px 2px;
- /* 字体大小 */
- font-size: 30px;
- /* 字体加粗 */
- font-weight: bold;
- /* 斜体 */
- font-style: italic;
- }
- a{
- text-decoration: none;
- }
- h1{
- /* 去掉加粗 */
- font-weight: normal;
- /* 设置字体 */
- /* font-family: '隶书'; */
- /* 字体大小和字体一起设置 */
- font: 20px cursive;
- }
- </style>
- </head>
- <body>
- <h1>这是个h1</h1>
- <div>文本和字体</div>
- <a href="">超链接</a>
- </body>
- </html>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <style type="text/css">
- #i-1{
- width: 100px;
- height: 30px;
- background-color: #7FFF00;
- color: red;
- text-align: center;
- line-height: 30px;
- }
- span{
- font-size: 25px;
- font-style: italic;
- }
- #i-2{
- font-weight: normal;
- text-shadow: aqua -10px 10px 3px;
- }
- #i-3{
- text-decoration: underline;
- }
- a{
- text-decoration: none;
- font-weight: bold;
- font-size: 20px;
- }
- </style>
- </head>
- <body>
- <div id="i-1">刘德华</div>
- <div>张学友</div>
- <span>香蕉</span>
- <span>苹果</span>
- <h1 id="i-2">冰箱</h1>
- <h1 id="i-3">洗衣机</h1>
- <a href="http://www.baidu.com">百度</a>
- </body>
- </html>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- div{
- width: 100px;height: 100px;
- border: 1px solid red;
- }
- span{
- border: 1px solid blue;
- /*行内元素宽高不能修改*/
- width: 100px;height: 100px;
- }
- img{
- /*行内块元素 共占一行并且可以修改宽高*/
- width: 100px;
- height: 100px;
- /*隐藏元素*/
- display: none;
- }
- a{
- background-color: #0aa1ed;
- /*行内元素无法修改宽高,如果必须改,需要将元素改成块级元素或行内块元素*/
- display: block;
- width: 132px;
- height: 40px;
- text-align: center;
- line-height: 40px;
- color: white;
- font-size: 20px;
- text-decoration: none;
- border-radius: 3px;/*设置圆角 值越大越圆*/
- }
- </style>
- </head>
- <body>
- <a href="">查看详情</a>
- <img src="../b.jpg" alt="">
- <img src="../b.jpg" alt="">
- <img src="../b.jpg" alt="">
- <div>div1</div>
- <div>div2</div>
- <div>div3</div>
- <span>span1</span>
- <span>span2</span>
- <span>span3</span>
-
- </body>
- </html>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- div{width: 100px;height: 100px;border: 1px solid red}
- #d1{
- /*margin-left: 50px;
- margin-top: 50px;
- margin-bottom: 50px;
- margin-right: 50px;*/
- margin: 50px;/*四个方向50个像素的外边距*/
- margin: 50px 100px;/*上下50和左右100*/
- margin: 10px 20px 30px 40px;/*上右下左*/
- }
- #d2{
- /*上下相邻两个元素彼此添加外边距 取最大值*/
- margin-top: 50px;
- }
- #s1{
- /*行内元素上下外边距无效*/
- margin-bottom: 100px;
- margin-right: 50px;
- }
- #s2{
- /*左右相邻彼此添加外边距两者相加*/
- margin-left: 50px;
- }
-
- </style>
- </head>
- <body>
- <span id="s1">span1</span><span id="s2">span2</span>
- <div id="d1">div1</div>
- <div id="d2">div2</div>
- </body>
- </html>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- #d1{
- width: 200px;
- height: 200px;
- background-color: red;
- overflow: hidden;/*解决粘连问题*/
- }
- #d1>div{
- width: 50px;
- height: 50px;
- background-color: blue;
- margin-left: 50px;
- /*当元素的上边缘和上级元素的上边缘重叠时
- 给元素添加上外边距会出现粘连问题,给上级元素添加overflow:hidden解决*/
- margin-top: 100px;
- }
- #d2{
- width: 100px;
- height: 100px;
- border: 10px solid red;
- /*设置圆角 超过宽高一半为正圆*/
- border-radius: 100px;
- }
- #d3{
- width: 50px;
- height: 50px;
- border: 1px solid blue;
- /*给元素添加内边距 会影响元素的宽高*/
- padding-left: 50px;
- padding-top: 50px;
- }
-
- </style>
- </head>
- <body>
- <div id="d3">内边距</div>
- <div id="d2">边框测试</div>
- <div id="d1">
- <div></div>
- </div>
- </body>
- </html>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- #d1{
- width: 100px;
- height: 100px;
- background-color: red;
- margin: 25px 0 0 25px;
- overflow: hidden;
- }
- #d1>div{
- width: 50px;
- height: 50px;
- background-color: blue;
- margin: 25px 0 0 25px;
- }
- #d2{
- width: 50px;
- height: 50px;
- border: 5px solid green;
- border-radius: 5px;
- margin-left: 125px;
- padding: 50px 0 0 50px;
- }
-
-
- </style>
- </head>
- <body>
- <div id="d1">
- <div></div>
- </div>
- <div id="d2">哈喽</div>
- </body>
- </html>