PHP界面复用以及利用after伪类元素清除浮动float所产生的塌陷

controllers代码:

<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/24
 * Time: 16:15
 */
class MyTest extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
    }
    function test1(){
        $this->load->view('/mytest/one');
        $this->load->view('/mytest/two');
        $this->load->view('/mytest/three');
        $this->load->view('/mytest/five');
        $this->load->view('/mytest/four');

    }
    function test2(){
        $this->load->view('/mytest/one');
        $this->load->view('/mytest/two');
        $this->load->view('/mytest/three');
        $this->load->view('/mytest/five_2');
        $this->load->view('/mytest/four');
    }

views代码:

one

<!doctype html>
<html>

<body>

<div style="border: 2px solid  chartreuse;margin-top: 20px">

    <p>我是div111</p>

</div>
</body>

</html>

two

<!doctype html>
<html>

<style>
    .big {
        border: 4px solid red;
        position: relative;
        width: 100%;
        height: 600px;
        margin-top: 20px
    }

    /*对big标签的所有子元素都向右浮动*/
    .big > * {
        float: left;
        margin-left: 20px;
    }

    /*清除浮动*/
    .big:after {
        content: ".";
        display: block;
        height: 0;
        clear: both;
        visibility: hidden;
    }

    .two{
        border:4px solid #fcff32;
        width: 200px;
        height: 200px;
        float: left;
        margin-top: 10px
    }


</style>


<body>
<div class="big">
    <strong>我是大的容器</strong>
    <div class="two">

        <p>我是div222</p>

    </div>


</body>

</html>

three

<!doctype html>
<html>
<body>

<div style="border: 2px solid  #27fffc;width: 500px;float: left;height: 500px;margin-top: 10px">

    <p>我是div333</p>

</body>

</html>

four

<!doctype html>
<html>
<head>

</head>
<body>

<div style="border: 2px solid  #212fff;margin-top: 10px" >

    <p>我是div444</p>

</div>
</body>

</html>

five

<!doctype html>
<html>

<style>
    #five{
        border: 2px solid  #b328ff;
        position: absolute;
        clear: both;
        float: right;
        margin-left: 410px;
        margin-top: -50px;
    }
</style>
<body>

<div id="five" >

    <p>我是div555</p>

</div>

</div>

</div>

</body>

</html>

five_2

<!doctype html>
<html>

<body>

<div style="border: 2px solid  #b328ff;position: absolute;float: right">

    <p>我是被复用的div555</p>

</div>

</div>

</div>

</body>

</html>

效果:
这里写图片描述

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值