文本可以沿斜线左对齐吗?对齐方式应符合倾斜形状,兼容 IE9 浏览器。
考虑以下代码示例:
<code class="html"><img src="http://placehold.it/150x250&text=img" alt="image" /> <p>Lorem ipsum dolor sit amet. Vestibulum commodo volutpat a, convallis ac, laoreet enim. Phasellus fermentum in, dolor. Pellentesque facilisis. Nulla imperdiet sit amet magna. Vestibulum dapibus, mauris nec malesuada fames ac turpis velit, rhoncus eu,luctus et interdum adipiscing wisi. Aliquam erat ac ipsum. Integer aliquam purus. Quisque lorem tortor fringilla sed, vestibulum id, eleifend justo vel bibendum sapien massa ac turpis faucibus orci luctus non, consectetuer lobortis quis, varius in, paragraph.</p></code>
<code class="css">img { display: block; float: left; transform: rotate(-5deg); margin: 0 15px; }</code>
作为标准 CSS 方法的补充,一种更非常规的解决方案包括添加方形元素并计算其大小:
<code class="less">.loop(@i) when (@i > 0){ .loop((@i - 1)); .space@{i}{ width: floor(@i*@hSize/(1/tan(5deg))); } } @hSize: 15px; .space { float: left; clear: left; width: @hSize; height: @hSize; }</code>
HTML 如下:
<code class="html"><p> <span class="space space1"></span> <span class="space space2"></span> <!-- (...) --> <span class="space space11"></span> Lorem ipsum dolor sit amet. Vestibulum commodo volutpat a, convallis ac, laoreet enim. Phasellus fermentum in, dolor. Pellentesque facilisis. Nulla imperdiet sit amet magna. Vestibulum dapibus, mauris nec malesuada fames ac turpis velit, rhoncus eu, luctus et interdum adipiscing wisi. Aliquam erat ac ipsum. Integer aliquam purus. Quisque lorem tortor fringilla sed, vestibulum id, eleifend justo vel bibendum sapien massa ac turpis faucibus orci luctus non, consectetuer lobortis quis, varius in, paragraph. </p></code>
这里有一个实际示例来演示实际的解决方案:http://codepen.io/Tymek/pen/jEypOX?editors=110
以上是IE9 中文本可以沿斜线左对齐吗?的详细内容。更多信息请关注PHP中文网其他相关文章!