css 实现简单的评论布局

1:float实现

<!doctype html>
<html>
    <head>
        <title>hello</title>
        <style type="text/css">
            .content{
                width:1000px;
                height:500px;
                background: #ff0;
            }
            .cell{
                width:600px;
                height:100px;
                margin-bottom:10px;
                background: #f0f;
            }
            .img{
                float: left;
                width: 20%;
                height:100px;
                margin-right: 2%;
            }
            .text{
                float:right;
                width:78%;
                height:100px;   
            }
            img{
                width:100px;
                height:100px;
            }
            .title{
                font-size:20px;
                font-weight: 700;

            }
            .pcontent{
                font-size: 18px;
                font-weight: 400;
            }
        </style>
    </head>

    <body>
        <div class="content">
            <div class='cell'>
                <div class='img'>![](timg.jpg)</div>
                <div class='text'>
                    <p class='title'>title1</p>
                    <p class='pcontent'>pppppppppppppppppppppppppp</p>
                </div>
            </div>
            <div class='cell'>
                <div class='img'>![](timg.jpg)</div>
                <div class='text'>
                    <p class='title'>title2</p>
                    <p class='pcontent'>pppppppppppppppppppppppppp</p>
                </div>
            <div>
        </div>
    </body>
</html>

显示结果:


image.png

2:flex实现

<!doctype html>
<html>
<head>
    <title></title>
    <style type="text/css">
        .content{
            height:500px;
            width:1000px;
            background: #ff0;
        }
        .cell{
            width:100%;
            height:100px;
            margin-bottom: 10px;
            display: flex;
        }
        .img{
            flex:0 0 15%;
        }
        img{
            width:100px;
        }
        .text{
            flex: 0 0 80%;
        
        }
        .title{
            font-size:20px;
            font-weight: 700;

        }
        .pcontent{
            font-size: 18px;
            font-weight: 400;
        }
    </style>
</head>
<body>
        <div class="content">
            <div class='cell'>
                <div class='img'>![](timg.jpg)</div>
                <div class='text'>
                    <p class='title'>title1</p>
                    <p class='pcontent'>pppppppppppppppppppppppppp</p>
                </div>
            </div>
            <div class='cell'>
                <div class='img'>![](timg.jpg)</div>
                <div class='text'>
                    <p class='title'>title2</p>
                    <p class='pcontent'>pppppppppppppppppppppppppp</p>
                </div>
            <div>
        </div>
    
</body>

</html>

展示结果:


image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 13,801评论 1 92
  • 使用纯 CSS 实现 500px 照片列表布局 文章很长,因为介绍了如何一步一步进化到最后接近完美的效果的,不想读...
    HZ充电大喵阅读 2,674评论 0 4
  • 移动开发基本知识点 一.使用rem作为单位 html { font-size: 100px; } @media(m...
    横冲直撞666阅读 3,514评论 0 6
  • H5移动端知识点总结 阅读目录 移动开发基本知识点 calc基本用法 box-sizing的理解及使用 理解dis...
    Mx勇阅读 4,625评论 0 26
  • (D5/21 Q2) 一转眼,出来工作也7年了。从菜鸟到司机的变化,其中有太多的故事和人物要说也说不完。 ...
    中华燕阅读 270评论 3 0