最近很多小伙伴都在问【代码笔记】Web-CSS-CSSDisplay和css+div代码大全这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展css–display:blockins
最近很多小伙伴都在问【代码笔记】Web-CSS-CSS Display和css+div代码大全这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展css – display:block inside display:inline、css – display:inline vs display:block、CSS:display:block; vs display:table;、display.display(gcf()) 和 display.clear_output(wait=False) 命令的作用是什么?等相关知识,下面开始了哦!
本文目录一览:- 【代码笔记】Web-CSS-CSS Display(css+div代码大全)
- css – display:block inside display:inline
- css – display:inline vs display:block
- CSS:display:block; vs display:table;
- display.display(gcf()) 和 display.clear_output(wait=False) 命令的作用是什么?
【代码笔记】Web-CSS-CSS Display(css+div代码大全)
一,效果图。
二,代码。
<!DOCTYPE html>
<html> <head> <meta charset="utf-8"> <title>CSS Display(显示)</title> <style> h1.hidden { display: none; } li { display: inline; } span { display: block; } </style> </head> <body> <h1>this is a visible heading</h1> <h1 class="hidden">this is a hidden heading</h1> <p>notice that the hidden heading still takes up space.</p> <ul> <li><a href="/html" target="_blank">HTML</a></li> <li><a href="/css/" target="_blank">CSS</a></li> <li><a href="/js/" target="_blank">JavaScript</a></li> <li><a href="/xml/" target="_blank">XML</a></li> </ul> <h2>nirvana</h2> <span>Record: MTV Unplugged in New York</span> <span>Year: 1993</span> <h2>Radiohead</h2> <span>Record: OK Computer</span> <span>Year: 1997</span> </body> </html>
参考资料:《菜鸟教程》
css – display:block inside display:inline
这种情况在CSS 2.1规范的Anonymous block boxes部分中描述:该示例包括以下规则…
body { display: inline } p { display: block }
…和随附的文字说…
The BODY element contains a chunk (C1)
of anonymous text followed by a
block-level element followed by
another chunk (C2) of anonymous text.
The resulting Boxes would be an
anonymous block Box around the BODY,
containing an anonymous block Box
around C1,the P block Box,and
another anonymous block Box around C2.
如果你有一个display:inline parent元素,如果这个父级有一个子元素是display:block,那么该子元素的存在似乎使父元素几乎像display:block,并且忽略它被定义为display :inline(因为父元素现在只包含匿名和非匿名块子元素,即它不再包含任何内联子元素)?
我的问题是,在这种情况下(有一个显示:块子)然后什么是父的定义显示之间的差异:内联而不是显示:块?
编辑:我更感兴趣了解CSS 2.1标准比如何和是否各种浏览器实现在实践中的行为。
第二编辑:
规格中注明了一个差异。在下面的文档中,第二’块’段的边框围绕整个段落和页面的整个宽度;而第一’内嵌段落的边框在段落内的每一行(即使有多行),并且不超过每行的精确宽度(每行小于页面宽度)。
<html> <head> <style type="text/css"> p.one { border-style:solid; border-width:1px; display: inline; } p.two { border-style:solid; border-width:1px; } </style> </head> <body> <p>Some text. <b>Note:</b> The "border-width" property does not work if it is used alone. Use the "border-style" property to set the borders first.</p> <p>Some text.</p> </body> </html>
如果我添加以下样式规则…
b { display: block; }
…然后,在第一个内联段落中的“注意:”变成一个块,它分割段落(根据规范,段落的第一和最后部分现在在一个匿名块)。但是,段落的第一部分和最后部分的边界仍然是“内联”样式的边界:因此,仍然不同于p.one已被声明为display:block。
有一个引用规范,说,
Properties set on elements that cause
anonymous block Boxes to be generated
still apply to the Boxes and content
of that element. For example,if a
border had been set on the BODY
element in the above example,the
border would be drawn around C1 (open
at the end of the line) and C2 (open
at the start of the line).
是“border-style”属性是唯一可以看到差异的属性类型吗?
解决方法
When an inline Box contains a block Box,the inline Box […] [is] broken around the block. The [in]line Boxes before the break and after the break are enclosed in anonymous Boxes,and the block Box becomes a sibling of those anonymous Boxes.
<BODYhttps://www.jb51.cc/tag/dis/" target="_blank">display: inline; "> This is anonymous text before the P. <P>This is the content of P.</P> This is anonymous text after the P. </BODY>
The resulting Boxes would be an anonymous block Box around the BODY,containing an anonymous block Box around C1,and another anonymous block Box around C2.
或者,视觉上:
+- anonymous block Box around body ---+ | +- anonymous block Box around C1 -+ | | | + | | +---------------------------------+ | | | | +- P block Box -------------------+ | | | + | | +---------------------------------+ | | | | +- anonymous block Box around C2 -+ | | | + | | +---------------------------------+ | +-------------------------------------+
现在到您的问题:这是不同于< BODY style =“display:block;”> ;? 是的。而它仍然是4盒(匿名块框周围的身体现在是BODY块盒),规格告诉区别:
Properties set on elements that cause anonymous block Boxes to be generated still apply to the [generated anonymous block] Boxes and content of that element. For example,if a border had been set on the BODY element in the above example,the border would be drawn around C1 (open at the end of the line) and C2 (open at the start of the line):
+-------------------------------------- | This is anonymous text before the P. +-------------------------------------- This is the content of P. --------------------------------------+ This is anonymous text after the P. | --------------------------------------+
这不同于< BODY style =“display:block;”> ;:
+--------------------------------------+ | This is anonymous text before the P. | | | | This is the content of P. | | | | This is anonymous text after the P. | +--------------------------------------+
css – display:inline vs display:block
display:inline
和这个?
display:block`
在一个元素上单独使用这些,我得到相同的结果。
解决方法
display:inline表示元素在同一行上的当前块内内联显示。只有当它在两个块之间时,该元素形成“匿名块”,然而具有最小可能的宽度。
阅读更多关于显示选项:http://www.quirksmode.org/css/display.html
CSS:display:block; vs display:table;
有没有之间的差异display:block;
和display:table;
?在我看来,包含table-row
和table-cell
节点的dom节点的显示类型无关紧要。MDN表示这display:table;
使其表现得像表,但并未详细说明该行为是什么。那是什么行为?
同样,display:inline-block;
和之间有区别display:inline-table;
吗?
答案1
小编典典比较这两个(块和表),我不知道您会在真空中看到任何核心差异(可能有微小差异)。我相信主要区别在于儿童。表格及其子元素与div及其子元素具有非常不同的属性/关系。
至于inline-block和inline-table,请参见:inline-block和inline-
table有[什么区别?
本文提供了一些有趣的信息,特别是有关与表相关的所有不同显示属性的信息。
display.display(gcf()) 和 display.clear_output(wait=False) 命令的作用是什么?
如何解决display.display(gcf()) 和 display.clear_output(wait=False) 命令的作用是什么?
我不知道以下代码中的逗号 display.display(gcf())
和 display.clear_output(wait=False)
究竟是做什么的?
我们可以使用 bar(range(len(A)),A,color = color)
绘制绘图。我不知道为什么我们使用命令 display.display(gcf())
和 display.clear_output(wait=False)
。
from IPython import display
import time
def array_plot(A):
clf()
color = ["blue"] * len(A)
bar(range(len(A)),color = color)
display.display(gcf())
display.clear_output(wait=False)
time.sleep(0.10)
我们今天的关于【代码笔记】Web-CSS-CSS Display和css+div代码大全的分享就到这里,谢谢您的阅读,如果想了解更多关于css – display:block inside display:inline、css – display:inline vs display:block、CSS:display:block; vs display:table;、display.display(gcf()) 和 display.clear_output(wait=False) 命令的作用是什么?的相关信息,可以在本站进行搜索。
本文标签: