利用基础知识学习制作简单浮动

原创 2018-12-17 11:22:49 157
摘要:<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>盒子模型-相对定位</title>    <style> /*1.

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>盒子模型-相对定位</title>
   <style>
/*1. 子元素是单行行内元素: 如a, span <br>*/
       /*a:水平居中: 在父元素应用: text-align: center;*/
       /*b:垂直居中: 在行内子元素上设置行高与父元素等高: line-height:200px;*/

.box1 a,.box2 a,.box3 a,.box4 a{
           line-height: 302px; /*群定义所有box里面的a*/

}
       .box1 {
           width: 300px;/*宽*/
height: 300px;/*高*/
padding: 1px;/*所有外边距*/
border:1px solid;/*外边框大小*/
border-color: #010006;/*外边框颜色*/
background-color: lightgreen;/*背景*/
text-align: center;/*水平居中*/
position: relative;
left: 303px;
top: 0;
}
       .box2 {
           width: 300px;/*宽*/
height: 300px;/*高*/
padding: 1px;/*所有外边距*/
border:1px solid;/*外边框大小*/
border-color: #fe190e;/*外边框颜色*/
background-color: #ee8fca;
text-align: center;
position: relative;
left: 0px;
top: 0px;
}
       .box3 {
           width: 300px;/*宽*/
height: 300px;/*高*/
padding: 1px;/*所有外边距*/
border:1px solid;/*外边框大小*/
border-color: #191cfb;/*外边框颜色*/
background-color: #c5ee46;
text-align: center;
position: relative;
left: 606px;
top:-304px;
}
       .box4 {
           width: 300px;/*宽*/
height: 300px;/*高*/
padding: 1px;/*所有外边距*/
border:1px solid;/*外边框大小*/
border-clor: #fb357a;/*外边框颜色*/
background-color: #15e9ee;
text-align: center;
position: relative;
left: 303px;
top:-304px;
}

   </style>
</head>
<body>
<div class="box1">
   <a>php中文网</a>
</div>
<div class="box2">
   <a>php中文网</a>
</div>
<div class="box3">
   <a>php中文网</a>
</div>
<div class="box4">
   <a>php中文网</a>
</div>
</body>
</html>

批改老师:天蓬老师批改时间:2018-12-17 11:28:26
老师总结:盒子模型, 是布局的基础 , 不过, 现在有了一些盒子模型的替代方案, 需要 css3支持, 有兴趣,可以了解了一下

发布手记

热门词条