发表于: 2018-07-09 23:39:57

0 631


今天主要的学习内容是html+css制作一个自适应能够在手机上访问的九宫格

一、html

1.一个标记语言,html页面由浏览器解析执行。

2.选择的编译工具为sublime,浏览器为chrome

3.语法

①标记必须小写

②标记必须关闭 

③属性值必须有引号

④标签要严格封闭

。。。。

4.基本结构

<!DOCTYPE html>文档声明头

<html lang="en">

<head>头标签 表示页面配置

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>主体部分

</body>

</html>

5.标签类型

①.排版标签

②字条标签

③超链接

④图片标签

。。。。

6.css概述

给html页面标签添加样式,定义显示效果

<style type="text/css">      代码

p{        

          font-weight: bold;    样式     

          font-style: italic;        

          color: red;    

}

使用方法:

行内样式表 直接在标签里使用style属性

内嵌样式表 在head中使用<style>标签

引入外部样式表 在head中使用link标签


选择器  选择那些标签使用那些样式

标签选择器 一类标签都用这种样式

id选择器   某一个id对应一种样式 标签加上这个id就可以使用这种样式

类选择器  .定义样式 不用标签加上这个属性就可以使用这种样式

通配选择器  *全部使用某种样式


7.盒子模型+浮动


练习:

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<meta name=keywords content="" >

<meta name=description content="">

<title>zuoye</title>

<style type="text/css">

        *{

            margin: 0

            padding: 0;

        }

        .header{

         height: 103px;

         width: 970px;

         margin:0 auto;

        }

.box1{

float: left;

height: 103px;

width: 277px;

background-color: red;

margin-bottom: 10px;

}

.box2{

float: right;

height: 49px;

width: 137px;

background-color: green;

            margin-bottom: 8px

}

        .box3{

         float: right;

         height: 46px;

         width: 679px;

         background-color: green;

         margin-bottom: 10px;

        }

        .medium{

         height:435px;

         width:970px;

         margin:0 auto;

         margin-bottom: 20px;

        }

        .box4{

         float: left;

         height: 435px;

         width: 310px;

         background-color:gold;

         margin-bottom: 10px;

         margin-right: 10px;

        }

        .box5{

         float: left;

         height: 240px;

         width: 450px;

         background-color: powderblue;

         margin-bottom: 10px;

        }

        .box6{

         float: left;

         height: 110px;

         width: 450px;

         background-color: powderblue;

         margin-bottom: 10px;

        }

        .box7{

         float: left;

         height: 30px;

         width: 450px;

         background-color: powderblue;

         margin-bottom: 10px;

        }

        .box8{

         float: right;

         height: 400px;

         width: 190px;

         background-color: purple;

         margin-bottom: 10px;

        }

        .box9{

         float: left;

         height: 25px;

         width: 650px;

         background-color: green;

         margin-bottom: 10px;

        }

        .buttom{

         height: 35px;

         width: 970px;

         background-color: skyblue;

         margin:0 auto;

        }

</style>

</head>

<body>

<div class="header">

<div class="box1"></div>

<div class="box2"></div>

<div class="box3"></div>

</div>

<div class="medium">

<div class="box4"></div>

<div class="box8"></div>

<div class="box5"></div>

<div class="box6"></div>

<div class="box7"></div>

<div class="box9"></div>

</div>

<div class="buttom"></div>

</body>

</html>



返回列表 返回列表
评论

    分享到