【发布时间】:2020-07-23 08:21:58
【问题描述】:
我的 Google 字体的斜体非常微妙,所以我尝试使用 CSS transform: skew 元素添加额外的斜体。我将文本包裹在一个跨度中,但为了让转换属性起作用,我也在使用display: inline-block。但是,在列表项中使用此方法时,它会强制将列表项的一半放到新行上。有谁知道如何防止这种情况?
强制换行的列表项截图:
.slant {
transform: skew(-8deg);
display: inline-block;
}
<ul>
<li>Ripley, John W. (Ed.).1975. <span class="slant">Those Dreadful Devil Wagons: Shawnee County’s Automobile Owners, Dealers and Manufacturers</span>, 1902-1912 (Shawnee County Historical Society Bulletin No. 49).</li>
<li>Boyd, John/Toronto Star [Photographer]. (1900). Cars; trucks and horse-drawn wagons competed for space at fruit and vegetable whole. [Photograph], Retrieved May 6, 2020, from: <a href="https://www.gettyimages.com/detail/news-photo/cars-trucks-and-horse-drawn-wagons-competed-for-space-at-news-photo/502831383"
target="_blank">https://www.gettyimages.com/detail/news-photo/cars-trucks-and-horse-drawn-wagons-competed-for-space-at-news-photo/502831383</a></li>
<li>Daily Herald [Photographer]. Hospital X-ray, 1932 [Photograph], Retrieved May 6, 2020, from: <a href="https://www.gettyimages.com/detail/news-photo/hospital-x-ray-1932-a-photograph-of-staff-taking-an-x-ray-news-photo/102730396" target="_blank">https://www.gettyimages.com/detail/news-photo/hospital-x-ray-1932-a-photograph-of-staff-taking-an-x-ray-news-photo/102730396</a></li>
</ul>
【问题讨论】:
-
我倾向于避免使用斜体标签,因为它没有语义,不会在屏幕阅读器中显示,并且会导致 WCAG 错误。我只是为了好玩而尝试它,它仍然存在与 span 和 em 标签相同的问题。不过,感谢您的意见。
-
尝试使用:word-break: break-all;
-
@AlyJ
i标签工作正常:jsfiddle.net/mhb7ow8k -
为什么不直接使用
font-style: italic;?
标签: html css css-transforms