码迷,mamicode.com
首页 > Web开发 > 详细

Web全栈-盒子居中和内容居中

时间:2019-10-15 17:37:53      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:title   color   charset   作用   ima   内容   ext   src   ack   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>盒子居中和内容居中</title>
    <style>
        .father{
            width: 800px;
            height: 500px;
            background-color: red;
            /*text-align: center;*/
            margin:0 auto;
        }
        .son{
            width: 100px;
            height: 100px;
            background-color: blue;
        }
    </style>
</head>
<body>
<!--
1.text-align:center;和margin:0 auto;区别
text-align: center;作用
设置盒子中存储的文字/图片水平居中

margin:0 auto;作用
让盒子自己水平居中
-->
<div class="father">
    我是文字<br/>
    <img src="images/girl.jpg" alt="">
    <!--<div class="son"></div>-->
</div>
</body>
</html>

Web全栈-盒子居中和内容居中

标签:title   color   charset   作用   ima   内容   ext   src   ack   

原文地址:https://www.cnblogs.com/yindanny/p/11679035.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!