div布局

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>云API</title>
    <style>
        .empty{ text-align: center; padding: 120px 0; }
    </style>
</head>
<body>
    <!--<div class="empty">云API</div>-->
    <div style="display: flex;flex-flow: row wrap;align-content:space-around;padding-top:40px;width:100%;height:auto">
<div style="background-color: brown;width:100%;height:300px;margin-top: 10px">dsfsdf</div>
<!--元素水平垂直居中-->
<div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:center;display:flex;display: -webkit-flex; align-items:center;"><img  style="width:50%;height:50%;margin:0 auto;" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F00%2F93%2F35%2F3856f29579c538f.jpg&refer=http%3A%2F%2Fbpic.588ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1616551889&t=17c9affa4915dd8488d47e10607cb5d1"/></div>
<!--元素水平居中-->
<div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:center;margin:0 auto;"><img  style="width:50%;height:50%;" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F00%2F93%2F35%2F3856f29579c538f.jpg&refer=http%3A%2F%2Fbpic.588ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1616551889&t=17c9affa4915dd8488d47e10607cb5d1"/></div>
 <!--元素垂直居中-->
<div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:center;display:flex;display: -webkit-flex; align-items:center;"><img  style="width:50%;height:50%;" src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F00%2F93%2F35%2F3856f29579c538f.jpg&refer=http%3A%2F%2Fbpic.588ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1616551889&t=17c9affa4915dd8488d47e10607cb5d1"/></div>
    
    <!--文字垂直居中-->
    <div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red;display:flex;display: -webkit-flex; align-items:center;">ceshi</div>
        

    <!--文字水平居中-->
    <div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:center;">ceshi</div>
      
    <!--文字水平垂直居中  line-height: 300px;元素实际高度数值-->
    <div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:center;line-height: 300px;">ceshi</div>
        
    <!--文字水平靠左垂直居中  line-height: 300px;元素实际高度数值-->
    <div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:left;line-height: 300px;">ceshi</div>
        

    <!--文字水平靠右垂直居中  line-height: 300px;元素实际高度数值-->
    <div style="background-color: brown;width:100%;height:300px;margin-top: 10px;border:1px solid red; text-align:right;line-height: 300px;">ceshi</div>
        
    </div>



<div style="text-align: center;">文字水平居中</div>

<div style="display: table;"><div style="display: table-cell;vertical-align: middle;">文字垂直居中</div></div>

<div style="display: table;text-align: center;">
  <div style="vertical-align: middle;display: table-cell;">文字水平垂直居中</div>
</div>

</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容