TA的每日心情 | 开心 2021-3-12 23:18 |
|---|
签到天数: 2 天 [LV.1]初来乍到
|
|
margin在中文中我们翻译成外边距或者外补白。他是元素盒模型(box model)的基础属性。 margin,外边距可以把块级元素分开.外边距定义了围绕某种元素(elements)的空白. margin属性包括margin-top,margin-right,margin-bottom,margin-left,margin,可以用来设置box的margin area。属性margin可以用来同时设置box的四边外边距,而其他的margin属性只能设置其自各的外边距。
margin属性可以应用于几乎所有的元素,除了表格显示类型(不包括 table-caption, table and inline-table)的元素,而且垂直外边距对非置换内联元素(non-replaced inline element)不起作用。 。 或许有朋友对非置换元素(non-replaced element)有点疑惑,稍微帮助大家理解一下。非置换元素,W3C中没有给出明确的定义,但我们从字面可以理解到,非置换元素对应着置换元素(replaced element),也就是说我们搞懂了置换元素的含义,就懂了非置换元素。置换元素,W3C中给出了定义: . “An element that is outside the scope of the CSS formatter, such as an image, embedded document, or applet” ..
从定义中我们可以理解到,置换元素(replaced element)主要是指img,input,textarea,select,object等这类默认就有CSS格式化外表范围的元素。进而可知,非置换元素(non-replaced element)就是除了img,input,textarea,select,object等置换元素以外的元素。 margin始终是透明的。 ..
实例学习:
<HTML>
<head>
<title>CSS的margin边界应用范例</title>
<style type="text/css">
h1
{
margin-top:50px;
margin-left:85px;
margin-right:40px;
margin-bottom:30px;
background-color:blue;
}
p{
margin:10px;
background-color:gray;
}
u
{
margin:30px;
font-size:22px;
background-color:orange;
}
</style>
</head>
<body>
<center>
<h1>CSS中margin的应用</h1>
</center>
<p>行宫见月伤心色,夜雨闻铃肠断声。天旋地转回龙驭,到此踌躇不能去。</p>
<br />
<u>马嵬坡下泥土中,不见玉颜空死处。君臣相顾尽沾衣,东望都门信马归。归来池苑皆依旧,太液芙蓉未央柳。芙蓉如面柳如眉,对此如何不泪垂。春风桃李花开日,秋雨梧桐叶落时。西宫南内多秋草,落叶满阶红不扫。
</u>
</body>
</html>
源码下载:http://file.javaxxz.com/2014/11/3/235514093.zip |
|