inline 元素的特性
http://www.maxdesign.com.au/articles/inline/
http://www.w3.org/TR/CSS2/visuren.html#inline-boxes
http://www.w3.org/TR/CSS2/visudet.html#q4
inline不认高宽,不认上下的margin,不认overflow,但可以识别padding和左右方向的margin,也有line-height
inline属性的a标签,span标签支持margin-left与margin-right,margin-top无作用,而img标签margin四个方向都支持()。
本文章介绍了inline元素的padding,margin,width,height对元素本身的影响
要点:
块状元素前后元素会换行
行内元素前后元素不会换行
第一:行内元素与宽度
宽度不起作用
span {
width:200px;
}没有变化
第二:行内元素与高度
高度不起作用 但是高度可有line-height来确定
span{
height:200px;
}
没用变化
第三:行内元素与padding,margin
span{
padding:200px;
}
影响左右,不影响上下
如何实现
<ul>
<li>第一</li>
<li>第一</li>
<li>第一</li>
</ul>
中的li在同一行显示并有上下边距呢,
如果用display:inline,可行让其在一行内显示,但上下padding不起作用。
所以这种情况下用float:left;使其在一行内显示,并且其还是block元素,可以用
padding使与上下padding起作用,差生一定距离
The W3C’s CSS2 spec states that for Inline, non-replaced elements, the ‘width’ property does not apply
.
The W3C’s CSS2 spec states that for Inline, non-replaced elements, the ‘height’ property doesn’t apply, but the height of the box is given by the ‘line-height’ property
.
While padding can be applied to all sides of an inline element, only left and right padding will have an effect on surrounding content.

Margins operate in the same way as padding on inline elements. In the example below, 50px of margin has been applied to all sides of the <a> element. While the left and right edges are effected, the content above and below are not.
li 的padding和margin都正常生效 li是块级元素
| Element | Description |
|---|---|
<address> |
information on author |
<blockquote> |
long quotation |
<button> |
push button |
<caption> |
table caption |
<dd> |
definition description |
<del> |
deleted text |
<div> |
generic language/style container |
<dl> |
definition list |
<dt> |
definition term |
<fieldset> |
form control group |
<form> |
interactive form |
<h1> |
heading |
<h2> |
heading |
<h3> |
heading |
<h4> |
heading |
<h5> |
heading |
<h6> |
heading |
<hr> |
horizontal rule |
<iframe> |
inline subwindow |
<ins> |
inserted text |
<legend> |
fieldset legend |
<li> |
list item |
<map> |
client-side image map |
<noframes> |
alternate content container for non frame-based rendering |
<noscript> |
alternate content container for non script-based rendering |
<object> |
generic embedded object |
<ol> |
ordered list |
<p> |
paragraph |
<pre> |
preformatted text |
<table> |
table |
<tbody> |
table body |
<td> |
table data cell |
<tfoot> |
table footer |
<th> |
table header cell |
<thead> |
table header |
<tr> |
table row |
<ul> |
unordered list |
inline 元素的特性的更多相关文章
- inline元素、block元素、inline-block元素
inline 内联元素:是不可以控制宽和高.margin等:并且在同一行显示,不换行,直到该行排满. block 块级元素:是可以控制宽和高.margin等,并且会换行.块级对象元素会单独占一行显示, ...
- 关于block和inline元素的float
CSS float 浮动属性 本篇主要介绍float属性:定义元素朝哪个方向浮动. 目录 1. 页面布局方式:介绍文档流.浮动层以及float属性. 2. float:left :介绍float为 l ...
- inline元素、block元素
inline元素 不会独占一行,相邻的行内元素会排列在同一行内,直到一行排不下才会换行 高.行高.以及外边距和内边距不可改变 宽度就是它的文字或图片的宽度,不可改变,随元素内容变化而变化 内联元素只能 ...
- inline元素导航栏案例
练习一个超链接元素在文档流当中,a标签显示出来的inline这种元素的特性.我们可以用display来将它转换成inline-block类型,这样我们就可以设置它的高度,宽度和它的背景颜色等等特性了. ...
- display:inline-block,block,inline元素的区别
1.display:block将元素显示为块级元素,从而可以更好地操控元素的宽高,以及内外边距,每一个块级元素都是从新的一行开始.2.display : inline将元素显示为行内元素,高度,行高以 ...
- 返本求源——DOM元素的特性与属性
抛砖引玉 很多前端类库(比如dojo与JQuery)在涉及dom操作时都会见到两个模块:attr.prop.某天代码复查时,见到一段为某节点设置文本的代码: attr.set(node, 'inner ...
- 多个inline元素、block元素、inline-block元素在父容器中的换行情况
1.首先看inine元素的换行情况 <style> *{padding:0;margin:0} div.wrap{width:200px;height:200px;border:1px s ...
- inline元素的margin与padding
替换元素与非替换元素 替换元素(replaced element):所谓替换元素就是浏览器根据元素的标签和属性,来决定元素具体显示什么内容.比如说:img标签的src属性的值用来读取图片信息并且显示出 ...
- 当inline元素包裹block元素时会发生什么
经常有图片链接写法如下: <a href="www.baidu.com"><img src="baidu.jpg" /></a&g ...
随机推荐
- Java Learning Path(三)过程篇
Java Learning Path(三)过程篇 每个人的学习方法是不同的,一个人的方法不见得适合另一个人,我只能是谈自己的学习方法.因为我学习Java是完全自学的,从来没有问过别人,所以学习的过程基 ...
- ASP.NET CORE RAZOR :将文件上传至 ASP.NET Core 中的 Razor 页面
本部分演示使用 Razor 页面上传文件. 本教程中的 Razor 页面 Movie 示例应用使用简单的模型绑定上传文件,非常适合上传小型文件. 有关流式传输大文件的信息,请参阅通过流式传输上传大文件 ...
- win10 安装anaconda 无法使用pip 报错缺少SSL模块
在anaconda prompt里可以正常使用pip,普通cmd下activate后也可以使用.但不激活就不行. 解决方法: 是环境变量的问题. 安装anaconda需要添加三个环境变量,而不是只添加 ...
- [译]GLUT教程 - 键盘高级特性
Lighthouse3d.com >> GLUT Tutorial >> Input >> Advanced Keyboard 本节我们会介绍另外4个处理键盘事件的 ...
- 《HBase in Action》 第一章节的学习总结 ---- HBase是个啥
1.HBase模仿了Google的BigTable,是一种开源的,面向列族的数据库.它基于行键(rowkey),列键(column key)和时间戳(TimeStamp)来建立索引.HBase是建立在 ...
- 【SQLServer2008】之Win10 安装 SQL Server 2008
查看安装步骤链接: http://jingyan.baidu.com/article/1709ad8092be974634c4f0e7.html
- Java 异常介绍
Java标准库内建了一些通用的异常,这些类以 Throwable 为顶层父类.Throwable又派生出 Error 类和 Exception 类. 错误:Error类以及他的子类的实例,代表了JVM ...
- linux 解决 安装软件一直出现重复的信息
State : Sleeping, pid: Another app is currently holding the yum lock; waiting for it to exit... The ...
- git入门三(远程、标签)
git 入门三 (远程.标签) 分布式版本控制管理系统本地仓库和中心服务器仓库数据是本地的镜像仓库,中心服务器数据仓库的是为了多用户数据合并和获取同步的中心,多人协作需要管理这些远程仓库,以便 ...
- 解决ubuntukylin下各种终端字母重叠的方案
ubuntukylin14.04什么都挺好定符合中国人的使用习惯的,可是就是终端字母重叠的问题特别严重;(事实上ubuntu14.04也存在这个问题) 导致非常多非常好用的终端都使用不了,像guake ...