这是一个小提琴.
foo bar baz
和
a.infolink::before { content: '?'; background: blue; color: white; width: 20ex; height: 20ex; }
'?' 出现,但显然没有20ex大小.为什么不?在Firefox和Chrome中测试过.
::before
和::after
伪元素默认情况下,内联铺设,所以width
并height
不会生效.
设置它display: inline-block
,它应该工作.
在::before
和::after
伪元素实际上是display: inline;
默认.
将显示值更改inline-block
为宽度和高度生效:
a.infolink::before { content: '?'; display: inline-block; background: blue; color: white; width: 20px; height: 20px; }
http://jsfiddle.net/C7rSa/3/