【代码笔记】Web-CSS-CSS Align

2019-02-20 00:44:14来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

一,效果图。

 

二,代码。

复制代码
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>CSS Align</title>
    <style>
    body {
        margin: 0;
        padding: 0;
    }
    
    .container {
        position: relative;
        width: 100%;
    }
    
    .center {
        margin: auto;
        width: 70%;
        background-color: #b0e0e6;
    }
    
    .right {
        position: absolute;
        right: 0px;
        width: 300px;
        background-color: #b0e0e6;
    }
    
    .right {
        float: right;
        width: 300px;
        background-color: #b0e0e6;
    }
    </style>
</head>

<body>
    <div class="center">
        <p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.</p>
        <p>'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'</p>
    </div>
    <p><b>Note: </b>Using margin:auto will not work in IE8, unless a !DOCTYPE is declared.</p>
    <div class="right">
        <p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.</p>
        <p>'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'</p>
    </div>
    <div class="container">
        <div class="right">
            <p><b>Note: </b>When aligning using the position property, always include the !DOCTYPE declaration! If missing, it can produce strange results in IE browsers.</p>
        </div>
    </div>
    <div class="right">
        <p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.</p>
        <p>'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'</p>
    </div>
</body>

</html>
复制代码

 

参考资料:《菜鸟教程》

 


原文链接:https://www.cnblogs.com/yang-guang-girl/p/10393767.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:HTML之body标签中的相关标签补充

下一篇:第七课 路径与列表