2015-09-10 70 views

回答

1

認爲:before:after:left:right

兩個:left:right不存在的僞類,因此,你應該使用:before:after定位到任何你想要的左側和右側。

div { 
 
    margin: 0 auto; 
 
    background: blue; 
 
    width: 200px; 
 
} 
 
div:before { 
 
    position: relative; 
 
    left: -75px; 
 
    background: red; 
 
    content: 'To the left'; 
 
} 
 
div:after { 
 
    position: relative; 
 
    right: -75px; 
 
    background: green; 
 
    content: 'right'; 
 
}
<div>Some text</div>

要回答這個問題

是否有可能實現額外的僞類?

如何實現這樣的效果?

你將不得不使用額外的元素,並改變你的HTML以允許它。

+0

如果:之前和之後:如果已經使用 – Community

+0

如果您不介意javascript,請將其添加到JS中...... –

+0

問題是「是否有可能實現該目標?和「我如何實現這一目標?」 – Community

相關問題