day57 1.常用标签的使用: a | img | 列表标签 | meta | link 2.背景样式的使用(背景图片与 精灵图) ***** 3.边界圆角样式 4.盒子布局的总结(细节) 5.css样式的补充6.w3c页面

<!-- 今日内容:
1.常用标签的使用: a | img | 列表标签 | meta | link
2.背景样式的使用(背景图片与 精灵图) *****
3.边界圆角样式
4.盒子布局的总结(细节) *****
5.css样式的补充
6.w3c页面的书写



 

1.常用标签的使用: a | img | 列表标签 | meta | link

a标签的锚点使用:  开头的img标签、列表标签、meta标签、link标签设置页面头标
<!DOCTYPE html>
<
html> <head> <meta charset="UTF-8"> <title>常用标签的使用</title> <!-- SEO --> <!-- <meta name="keywords" content="8-12个以英文逗号隔开的单词或词语"> --> <!-- <meta name="description" content="80字以内的一段话,与网站内容相关"> --> <!-- 移动适配 --> <!-- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> --> <link rel="icon" type="image/x-icon" href="http://www.baidu.com/favicon.ico"> <style type="text/css"> .img { /*根据需求,是指定高还是指定宽,设置一个边,另一个会等比缩放*/ /*width: 200px;*/ height: 100px; } /*四个伪类的reset操作*/ a { color: #333; text-decoration: none; } /*ul的reset操作*/ ul { margin: 0; padding: 0; list-style: none; /*margin-left: 40px;*/ } </style> </head> <body> <!-- 1.设置锚点: 锚点名page_top --> <a href="" name="page_top"></a> <img class="img" src="./img/timg.jpg" alt=""> <a href="00_复习预习.html">前往00页面</a> <!-- 前往本页面中个某个位置: Top => 锚点 --> <!-- 步骤:1.设置锚点 2.设置前往锚点的a转跳 --> <ul> <li>列表项</li> <li>列表项</li> <li>列表项</li> <li>列表项</li> <li>列表项</li> </ul> <br> <br> <br> <br> <br> <br> <br> <!-- 通配标签页可以设置锚点 --> <!-- <a href="" name="t_123"></a> --> <div id="t_123">123</div> <br> <br> <br> <br> <br> <br> <br> <!-- 2.设置前往锚点的a转跳: #锚点名 --> <a href="#page_top">Top</a> <a href="#t_123">123</a> <a href="00_复习预习.html#md">前往锚点</a> </body> </html>

二。边界圆角

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>边界圆角</title>
    <style type="text/css">
        .box {
            width: 200px;
            height: 200px;
            background-color: orange;
        }
        .box {
            /*边界圆角*/

            /*百分比控制*/
            /*border-radius: 50%;*/

            /*实际像素控制*/
            /*border-radius: 20px;*/

            /*横纵分离  横 / 纵*/
            /*border-radius: 20px / 50%;*/

            /*左上为第一个角, 顺时针赋值, 无值找对角*/
            /*左上横30px 右上横100px 右下横=左上横 左下横=右上横, 四角纵向全是50%*/
            /*border-radius: 30px 100px / 50%;*/
            
            /*单独设置时, 横向 纵向*/
            /*border-top-left-radius: 50% 100%;
            border-top-right-radius: 50% 100%;*/
            
            border-radius: 50% 50% 0 0 / 100% 100% 0 0;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

三。背景样式(背景图片与 精灵图)

    背景图片

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>背景样式</title>
    <style type="text/css">
        .box, .wrap {
            width: 200px;
            height: 200px;
            background-color: orange;
        }
        .wrap {
            /*图片过大会显示不全*/
            background-image: url('img/timg.jpg');
            /*规定背景图片显示尺寸*/
            background-size: 200px 200px;
        }
        .box {
            /*图片过小会平铺*/
            background-image: url('img/123.png');
            /*平铺:repeat-x | repeat-y | repeat | no-repeat*/
            background-repeat: no-repeat;
            /*位置(定位): 可以写具体数值,也可以写位置单词*/
            /*background-position: 10px center;*/
            /*background-position: right bottom;*/
            /*background-position: center center;*/

            /*设置一个值时,控制的是x轴,y轴取center*/
            /*设置;两个值时,第一个值控制x,第二个值控制y*/
            background-position: 10px 40px;

            /*整体设置*/
            background: url('img/123.png') red no-repeat 50px 150px;
        }
        /*注: 实际开发中,资源图片大小一定要与显示区域等大*/
    </style>
</head>
<body>
    <img src="img/123.png" alt="">
    <div class="box"></div>
    <div class="wrap"></div>
</body>
</html>

    精灵图

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>精灵图</title>
    <style type="text/css">
        .box {
            width: 500px;
            height: 100px;
            /*height: 300px;*/
            border: 5px solid black;
        }
        .box {
            background-image: url('img/bg.png');
            background-position: 0 -150px;
        }
        .box:hover {
            cursor: pointer;
            background-position: 0 -250px;
        }
        /*1.显示区域一定要与精灵图目标小图大小一致*/
        /*2.通过背景图片定位方式将目标小图移至显示位置*/
    </style>

    <style type="text/css">
        .lt1 {
            width: 155px;
            height: 48px;
            background: url('img/bg.png') no-repeat 0 0;
        }
        .lt1:hover {
            cursor: pointer;
            background: url('img/bg.png') no-repeat 0 -48px;
        }
    </style>
</head>
<body>
    <!-- 精灵图: 是各种小图拼接起来的一张大图。 -->(很多小图之间有透明区域组成的大图eg:w3c精灵图)
    <!-- 为什么使用精灵图?: 减少请求次数, 降低性能的消耗, 二次加载图片资源时极为迅速(不在需要发送请求) -->
    <div class="box"></div>
    <div class="lt1"></div>
</body>
</html>

四。盒模型布局细节

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>盒模型布局细节</title>
    <style type="text/css">
        .sup {
            width: 500px;
            height: 100px;
            background: orange;
        }
        .sub {
            width: 50px;
            height: 50px;
            background-color: red;
        }
        /*sub在sup中 水平居中*/
        .sub {
            /*margin-left: auto;
            margin-right: auto;*/
            margin: 0 auto;
        }
        /*sub在sup中 垂直居中*/
        .sub {
            margin-top: 24px;
        }
        /*margin-top坑2: 父子联动*/
      解决三:设置一个高1px的第一子级。注意:会把sub盒子往下挤1px。
/*.box { width: 1px; height: 1px; }*/ /*解决一: 父级设置border-top*/同时设置父级高度,为了保证父级高度100不变。 .sup {。 /*border-top: 1px solid transparent; height: 99px;*/ } /*解决二: 父级设置padding-top*/同时设置父级高度,为了保证父级盒子高度100不变。 .sup { padding-top: 1px; height: 99px; } /*margin-top坑1: 上兄弟margin-bottom与下兄弟margin-top重合, 取大值*/   /*解决方案: 只设置一个,建议设置下兄弟margin-top*/ /*margin布局: 1.下盒子的垂直起始位置决定于同结构中上盒子的margin结束位置;
               2.子盒子水平起始位置就是父级content区域最左侧
*/ </style> </head> <body> <div class="sup"> <!-- <div class="box"></div> --> <div class="sub"></div> </div> </body> </html>

 

posted @ 2018-12-10 00:07  timm_book  阅读(61)  评论(0)    收藏  举报