5-H5样式控制CSS-盒子模型

#盒子模型

上课·记录·疑问

错误在高宽指内容即网页元素的。

左。。。

Input  none;去点击后出现的输入框

input{

            outlinenone;

        }

重置css

lh32

Pl.

Block?

课件

1边框说明表

2圆角边框

3盒子阴影

总结

代码

1边框样式

w宽度b边框

w、b:宽 线 颜色

<head lang="en">

    <meta charset="UTF-8">

    <title>边框</title>

    <style>

        

        .box{

           width298px;                 /* 盒子宽度298px*/

            border:1px solid #3a6587;    /* 设置盒子边框*/

        }

        h2{

            font-size:16px;

            background-color:#3a6587;

            height:35px;

            line-height:35px;

            color:#FFF;

        }

        form{

             background#c8ece3;

         }

        div:nth-of-type(1input{

            border3px solid black;     /* 第一个div下面的input元素设置边框3px 实线 黑色*/

        }

        div:nth-of-type(2input{

            border1px dashed red;  /* 第二个div下面的input元素设置边框1px 虚线 红色*/

        }

        div:nth-of-type(3input{

            border2px dotted red;   /* 第三个div下面的input元素设置边框2px 点线 红色*/

        }

    </style>

</head>

<body>

<div class="box">

    <h2>会员登录</h2>

    <form action="#">

        <div>

            <strong class="name">姓名:</strong>

            <input type="text"/>

        </div>

        <div>

            <strong class="name">邮箱:</strong>

            <input type="text"/>

        </div>

        <div>

            <strong class="name">电话:</strong>

            <input type="text"/>

        </div>

    </form>

</div>

</body>

2外边距margin

<head lang="en">

    <meta charset="UTF-8">

    <title></title>

    <style>

        body,h2{

            margin0;

        }

        .box{

           width298px;                 /* 盒子宽度298px*/

            border:1px solid #3a6587;    /* 设置盒子边框*/

            margin:0px auto;           /* 让整个盒子居中*/

        }

        h2{

            font-size:16px;

            background-color:#3a6587;

            height:35px;

            line-height:35px;

            color:#FFF;

        }

        div{

            margin-bottom6px;

        }

        form{

             background#c8ece3;

         }

    </style>

</head>

3margin居中条件

10 auto

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title></title>

    <style>

        *{

            margin0;

            padding0;

        }

        div{

            margin0 auto;

            border1px solid red;

        }

    </style>

</head>

<body>

    <div>我是div元素</div>

</body>

</html>

2width

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title></title>

    <style>

      span{

          width100px;

          margin0 auto;

          border1px solid red;

      }

    </style>

</head>

<body>

    <span>我是span元素</span>

</body>

</html>

4内边距padding-.||LR

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title></title>

    <style>

        body,h2{

            margin0;

            padding0;

        }

        .box{

           width298px;                 /* 盒子宽度298px*/

            border:1px solid #3a6587;    /* 设置盒子边框*/

            margin:0px auto;           /* 让整个盒子居中*/

        }

        h2{

            font-size:16px;

            background-color:#3a6587;

            height:35px;

            line-height:35px;

            color:#FFF;

            padding-left:20px;      /* 让标题左边留点空隙*/

        }

        div{

            margin-bottom6px;

        }

        form{

             background#c8ece3;

             padding:30px 10px;    /* 表单内部都设置空隙*/

         }

    </style>

</head>

<body>

<div class="box">

    <h2>会员登录</h2>

    <form action="#">

        <div>

            <strong class="name">姓名:</strong>

            <input type="text"/>

        </div>

        <div>

            <strong class="name">邮箱:</strong>

            <input type="text"/>

        </div>

        <div>

            <strong class="name">电话:</strong>

            <input type="text"/>

        </div>

    </form>

</div>

</body>

</html>

5盒模型尺寸WHPMB

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>盒模型尺寸</title>

    <style>

        div{

            width88px;

            height88px;

            padding5px;

            margin10px;

            border1px solid #000000;

        }

    </style>

</head>

<body>

    <div></div>

</body>

</html>

6box-sizing-未普及

计算盒子边框尺寸

不会往下掉的处理,即内部留出间隙

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>box-sizing</title>

    <style>

        div{

            width100px;

            height100px;

            padding5px;

            margin10px;

            border1px solid #000000;

            box-sizingborder-box;/*优秀*/

            /*box-sizing: content-box;  /!* 默认值*!/*/

        }

    </style>

</head>

<body>

    <div></div>

</body>

</html>

7border-radius左上对右下

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>border-radius的使用</title>

    <style>

        div{

            width100px;

            height100px;

            border10px solid red;

           /*border-radius: 20px;        /!*四个角都是圆角,值一样*!/*/

            /*border-radius: 20px 40px;     /!*左上右下是20px,右上左下是40px*!/*/

            /*border-radius: 20px  10px  50px;     /!*左上是20px,右上左下是10px, 右下是50px*!/*/

            border-radius20px  10px  50px  30px;     /*左上是20px,右上左下是10px, 右下是50px*/

        }

    </style>

</head>

<body>

    <div></div>

</body>

</html>

8border-radius制作特殊图形

1半圆50%左上右上0.50.500

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>border-radius制作半圆形</title>

    <style>

        div{

            backgroundred;

            margin30px;

        }

        div:nth-of-type(1){

            width100px;

            height50px;

            border-radius50px 50px 0 0;

        }

        div:nth-of-type(2){

            width100px;

            height50px;

            border-radius:0 0 50px 50px;

        }

        div:nth-of-type(3){

            width50px;

            height100px;

            border-radius:0 50px 50px  0;

        }

        div:nth-of-type(4){

            width50px;

            height100px;

            border-radius50px 0 0 50px;

        }

    </style>

</head>

<body>

    <div></div>

    <div></div>

    <div></div>

    <div></div>

</body>

</html>

2扇形0.5 000

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>border-radius制作扇形</title>

    <style>

        div{

            backgroundred;

            margin30px;

        }

        div:nth-of-type(1){

            width50px;

            height50px;

            border-radius50px 0 0 0;

        }

        div:nth-of-type(2){

            width50px;

            height50px;

            border-radius:0 50px 0 0;

        }

        div:nth-of-type(3){

            width50px;

            height50px;

            border-radius:0 0 50px 0;

        }

        div:nth-of-type(4){

            width50px;

            height50px;

            border-radius0 0 0 50px;

        }

    </style>

</head>

<body>

    <div></div>

    <div></div>

    <div></div>

    <div></div>

</body>

</html>

3圆形0.5

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>border-radius制作圆形</title>

    <style>

        div{

            width100px;

            height100px;

            border4px solid red;

            border-radius50%;

        }

    </style>

</head>

<body>

    <div></div>

</body>

</html>

9box-shadow

box-shadow: inset 3px 3px 10px #06c;   

            /*内阴影*/

 /* box-shadow:  3px 3px 10px #06c;   */

             /*外阴影*/

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>box-shadow的使用</title>

    <style>

        div{

            width100px;

            height100px;

            border1px solid red;

            border-radius8px;

            margin20px;

            /*box-shadow: 20px 10px 10px #06c;      /!*内阴影*!/*/

            /*box-shadow: 0px 0px 20px #06c;          /!*只设置模糊半径的阴影*!/*/

            box-shadowinset 3px 3px 10px #06c;   /*内阴影*/

        }

    </style>

</head>

<body>

<div></div>

</body>

</html>

10清除默认样式CSS

/* http://meyerweb.com/eric/tools/css/reset/

   v2.0 | 20110126

   License: none (public domain)

*/

html,

body,

div,

span,

applet,

object,

iframe,

h1,

h2,

h3,

h4,

h5,

h6,

p,

blockquote,

pre,

a,

abbr,

acronym,

address,

big,

cite,

code,

del,

dfn,

em,

img,

ins,

kbd,

q,

s,

samp,

small,

strike,

strong,

sub,

sup,

tt,

var,

b,

u,

i,

center,

dl,

dt,

dd,

ol,

ul,

li,

fieldset,

form,

label,

legend,

table,

caption,

tbody,

tfoot,

thead,

tr,

th,

td,

article,

aside,

canvas,

details,

embed,

figure,

figcaption,

footer,

header,

hgroup,

menu,

nav,

output,

ruby,

section,

summary,

time,

mark,

audio,

video {

  margin: 0;

  padding: 0;

  border: 0;

  font-size: 100%;

  font: inherit;

  vertical-align: baseline;

}

/* HTML5 display-role reset for older browsers */

article,

aside,

details,

figcaption,

figure,

footer,

header,

hgroup,

menu,

nav,

section {

  display: block;

}

ol,

ul {

  list-style: none;

}

blockquote,

q {

  quotes: none;

}

blockquote:before,

blockquote:after,

q:before,

q:after {

  content: "";

  content: none;

}

table {

  border-collapse: collapse;

  border-spacing: 0;

}

body,

button,

input,

select,

textarea {

  /* for ie */

  font: 12px/1 "微软雅黑", Tahoma, Helvetica, Arial, sans-serif;

  /* 用 ascii 字符表示,使得在任何编码下都无问题 */

  background: transparent;

}

a {

  text-decoration: none;

}

/* 伪元素 */

.clearfix::after {

  content: "";

  display: block;

  clear: both;

}

/* IE6,IE7 */

.clearfix {

  *zoom: 1;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值