gpt4 book ai didi

css - 如何通过 CSS 将 block 级元素转换为内联元素

转载 作者:行者123 更新时间:2023-12-02 01:18:37 25 4
gpt4 key购买 nike

假设我有这个内容:

<div class="entry">
<p>I want to display <br /><h2>heading level elements like this</h2>
<p> as inline elements on the same line with the text that preceded them as well as...</p>
<p>the text that<br />
<h3>(another heading element)</h3>
<p>, follows them...</p>
</p></p>
</div>

我希望标题元素在文本中内联显示,就好像它们只是粗体文本一样,与内容的大小相同。

在不改变内容的情况下,有什么 CSS 可以通过上面的示例实现这一点的想法吗?

最佳答案

使用 display:inline 属性:

.entry h2,  /* Combining two selectors: h2/h3 as a child of class=entry */
.entry h3 {
display: inline;
}

另请参阅:MDN, CSS display

关于css - 如何通过 CSS 将 block 级元素转换为内联元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8012947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com