CSS 转换不适用于内联元素

标签 css css-transforms

我想在单词 WEBLOG 中映射字母 E 所以我使用了 CSS transform 属性但是如果我将文本包装在一个 span 中它不起作用但是它有效如果我使用 display: inline-block;display: block;

那么转换不适用于内联元素?

Example 1 (转换失败)

<h1>W<span>E</span>BLOG</h1>

h1 span {
    transform:rotate(7deg);
    -ms-transform:rotate(7deg); /* IE 9 */
    -moz-transform:rotate(7deg); /* Firefox */
    -webkit-transform:rotate(7deg); /* Safari and Chrome */
    -o-transform:rotate(7deg); /* Opera */
}

Example 2 (有效,如果使用 display: blockdisplay: inline-block)

最佳答案

the official W3 specifications 中回答在 transformable element 下:

an element whose layout is governed by the CSS box model which is either a block-level or atomic inline-level element, or whose ‘display’ property computes to ‘table-row’, ‘table-row-group’, ‘table-header-group’, ‘table-footer-group’, ‘table-cell’, or ‘table-caption’ [CSS21]

关于CSS 转换不适用于内联元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56690867/

相关文章:

css - 如何使用 CSS 显示当前页面? .current_link 不工作

css - 为什么我的 webkit 渐变删除了我的 span 元素?

javascript - 如何使 HTML 父元素的边界框适合 CSS 转换后的子元素?

javascript - 在没有 mousemove 事件的情况下跟踪鼠标的相对位置

php - 有没有办法在 magento 的类别页面上创建选项卡

javascript - 导入 img 而不是 SVG

html - CSS3 : Adjust height of iframe to fit its content

html - 浏览器之间背面可见性的行为不一致

html - child 的 translateY 为负数,如何相应地调整 parent 的高度?

CSS 转换在 IE 8 中不起作用