我在我的博客上有一个问答页面,我想让它成为一个问题以一个大问号开始,答案以一个大惊叹号开始,那就是一个大写字母.使用::first-letter
个伪元素和initial-letter
个属性很容易实现这种效果,就像在这里提出的另一个问题(Drop-caps using CSS)中演示的那样,但问题是question mark and exclamation mark are not letters, therefore this approach does not work for them.有没有其他的解决方案呢?
我的临时解决方案是使用::before
伪类,但它只会使问号或感叹号更大,而不会使其成为首字母缩写.
我想知道是否有办法让问号深入段落,而不仅仅是变得更大.
.question::before {
content: '?';
font-size: 3em;
font-weight: 800;
padding: 15px;
display: inline-block;
}
<div class="question">I have a Q&A page in my blog, and I wanted to make it so the question starts with a large question mark, and the answer with a large exclamation mark, that is a drop cap. Such effect is easy to achieve with `::first-letter` pseudo-element and `initial-letter` property, but the problem is that question mark and exclamation mark are not letters, therefore these approach does not work for them. Is there an alternative solution for this?</div>