zoukankan      html  css  js  c++  java
  • CSS margin外边距实例

    文本的上边距设置用厘米

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8"> 
    <title>边距</title> 
    <style>
    p.ex1 {margin-top:2cm;}
    </style>
    </head>
    
    <body>
    
    <p>一个没有指定边距大小的段落。</p>
    <p class="ex1">一个2厘米上边距的段落。</p>
    <p>一个没有指定边距大小的段落。</p>
    
    </body>
    </html>

    set使用百分比值设置文本的下边距值

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8"> 
    <title>边距</title> 
    <style>
    p.bottommargin {margin-bottom:25%;}
    </style>
    </head>
    <body>
    
    <p>这是一个没有指定边距大小的段落。</p>
    <p class="bottommargin">这是一个指定下边距大小的段落。</p>
    <p>这是一个没有指定边距大小的段落。</p>
    
    </body>
    </html>

    所有的CSS边距属性

    属性描述
    margin 简写属性。在一个声明中设置所有外边距属性。
    margin-bottom 设置元素的下外边距。
    margin-left 设置元素的左外边距。
    margin-right 设置元素的右外边距。
    margin-top 设置元素的上外边距。

    今天通过一些实际的例子更加深入地理解了CSS margin外边距的使用与样式设计

    明天继续学习css相关样式

  • 相关阅读:
    事件
    dom对象
    逻辑运算和作用域的问题
    json
    数组
    字符串
    函数
    js的数据类型和全局方法
    js
    10.16 js内容
  • 原文地址:https://www.cnblogs.com/mjhjl/p/14901738.html
Copyright © 2011-2022 走看看