是否可以在不添加更多类或包装器元素的情况下使“和评论:”出现(显然有评论时)在对象名之后内联?我想让这个尽可能简单。我可以通过在评论中添加一个包装器来做到这一点,但这并不漂亮。
不工作:
.username, .objectname { font-weight:bold; }
.objectname:before {content: "'"; }
.objectname:after { content: "'"; }
.comment { font-style: italic; display: block; margin: 3px 0px 3px 0px; background-color: pink; }
.comment:before {content: "and commented:"; display:inline; background-color: purple;}
.eventtime { display: block; background-color: yellowgreen;margin: 3px 0px 3px 0px; color: #A1A1A0; }
<div class="item">
<span class="username">Some Person</span>
completed the task
<span class="objectname">A Random Task</span>
<span class="comment">silly comment silly comment silly comment silly comment silly comment silly comment silly</span>
<span class="eventtime">Today @ 12:37PM</span>
</div>
在职的:
.username, .objectname { font-weight: bold; }
.objectname:before {content: "'";}
.objectname:after { content: "'"; }
.comment { font-style: italic; display: block;margin: 3px 0px 3px 0px; background-color: pink;color: #919190;}
.commentwrapper:before {content: "and commented:"; display:inline; background-color: purple;}
.eventtime { display: block; background-color: yellowgreen;margin: 3px 0px 3px 0px; color: #A1A1A0; }
<div id="item1" class="item">
<span class="username">Some Person</span>
completed the task
<span class="objectname">A Random Task</span>
<span class="commentwrapper">
<span class="comment">silly comment silly comment silly comment silly comment silly comment silly comment silly comment silly comment silly comment silly comment silly comment silly comment</span>
</span>
<span class="eventtime">Today @ 12:37PM</span>
</div>