CSS具有内部样式和内联样式,可用于以内联方式显示段落元素。 CSS 是一种用于设计 HTML 和 XML 文本样式的语言。更改 HTML 元素的显示属性是一项典型的 CSS 工作。元素的显示属性指示其应如何呈现,例如块、内联或内联块。内联显示段落元素时,必须将显示属性从其默认块值修改为内联。
在这里,我们将学习如何开发将段落元素显示为内联的 CSS 代码。
语法
<p style="display : inline">..write the paragraph...</p>
HTML中的段落由p标签表示。显示属性定义内容的流动方式。
设置为显示“内联”的元素将显示为内联级框,这意味着它将在一行文本内流动。
相比之下,“块”元素将填充其父容器的整个宽度,并在任何现有内容下方添加新的内容行。
标题、段落和 div 元素是块级元素的示例,而链接、span 元素和图像是内联元素的示例。
使用的属性
示例中使用的以下属性是 -
颜色 - 定义文本的颜色。
background-color - 将文本定义为细或粗。
display - display 属性指定显示行为。
示例
在此示例中,我们将开始使用段落元素来设置几行文本。要将段落元素显示为内联,它将使用 display 属性通过内联 CSS 设置内联值。然后设计一些元素的样式,例如 body、p,以吸引网页上的用户交互。
<!DOCTYPE html> <html> <title>Display paragraph elements as inline using CSS</title> <head> </head> <body style="background-color: powderblue;"> <center> <h1 id="Rich-Dad-and-Poor-Dad">Rich Dad and Poor Dad</h1> </center> <p style="background-color:#a89032; color: white; font-style: italic; display: inline;">Rich Dad Poor Dad, by Robert Kiyosaki, was initially published in 1997 and immediately became a must-read for anybody interested in investment, money, or the global economy. The book has been translated into dozens of languages and sold all over the world, becoming the best-selling personal finance book of all time. Rich Dad Poor Dad's overriding theme is how to use money as a tool for wealth growth. It debunks the idea that the wealthy are born wealthy, explains why your personal residence may not be an asset, defines the distinction between an asset and a liability, and much more. </p> <p style="font-weight: bold; text-align: right; display: inline; color: darkgreen;">@tutorialspoint.com</p> </body> </html>
结论
在上面的输出中,我们可以看到如何借助 CSS 显示属性中的内联值来控制文本样式的布局。这是测试显示段落元素作为内联元素的变化的好主意。为了保持文本位置的灵活性,有时改变显示的属性是正确的。
以上是如何使用 CSS 将段落元素显示为内联?的详细内容。更多信息请关注PHP中文网其他相关文章!

在本周的综述中:datepickers正在让键盘用户头痛,一个新的Web组件编译器,有助于与Fouc进行战斗,我们终于获得了造型列表项目标记,以及在您的网站上获得网络攻击的四个步骤。

在本周的Web平台新闻世界中,Google搜索控制台可以更轻松地查看爬行的标记,我们了解到自定义属性


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

Dreamweaver Mac版
视觉化网页开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。