html – 显示标题内联以下段落
给出以下语义标记: <h3> SCOPE OF WORK. </h3> <p>Lorem ipsum dolor sit amet,consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <p>Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> 我想显示与段落内联的标题,如下所示:
选项1:浮动标题. 只要标题适合一行,这就可以工作.如果没有,浮点形成一个宽块,所以段落从块的右边开始,或者在下面而不是继续内联: | SCOPE OF | Lorem | | WORK | ipsum | | sit amet,consect| 选项2:内联显示两个元素. 样式规则如:h3,h3 * {display:inline;}可能有效.这假设它们先于&其次是块元素.否则,其他内联元素将流入其中.此外,相邻的选择器()并非在所有浏览器中都可用. 选项3? 无需添加不必要的类或包装元素,并使其保持有效&语义(段落中没有span.h3!),有没有更好的方法来做这个简单的事情? 解决方法<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style> h3 {display:run-in;} p { display:block; } div { width: 400px; } </style> </head> <body> <div> <h3> this is a title </h3> <p> this is a body of text,this is a body of text,this is a body of text</p> <p> this is a body of text,this is a body of text</p> </div> </body> </html> 这会将h3标签放入p标签中. (编辑:瑞安网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |