2014-09-25 26 views
0

我有一個問題。我試圖讓一個按鈕用CSS單擊右鍵:選擇器之後。:選擇器下的內容後?

.text-bg .text-top-left{ 
    position:absolute; 
    width:50%; 
    background:rgba(95,87,79,0.9); 
    padding:20px; 
    box-sizing:border-box; 
    -webkit-box-sizing:border-box; 
    top:50px; 
    left:-48%; 
} 

.text-bg .text-top-left:after{ 
    content:'>'; 
    font-family:'Entypo'; 
    width:20px; 
    height:10px;  
    color:black; 
    background:white; 
} 

現在>我的內容在我的文本左上角。但我需要它在右側,居中,在盒子外面。我需要改變什麼?

JsFiddle

嘗試:position:absolute, float:right, text-align:right

+2

你的代碼是很酷。但你可以擺弄你的代碼嗎? – 2014-09-25 10:13:45

+0

嘗試'位置:絕對;' – YvesHendseth 2014-09-25 10:16:32

+1

一點點的html將有助於頁面結構 – pistou 2014-09-25 10:16:39

回答

0

:after選擇玩弄top,left,right,bottom值。

演示:http://jsfiddle.net/lotusgodkk/w1v07drv/1/

CSS:

.text-bg .text-top-left { 
    position:absolute; 
    width:50%; 
    background:rgba(95, 87, 79, 0.9); 
    padding:20px; 
    box-sizing:border-box; 
    -webkit-box-sizing:border-box; 
    top:50px; 
    left:0; 
} 
.text-bg .text-top-left:after { 
    content:'>'; 
    font-family:'Entypo'; 
    width:20px; 
    height:10px; 
    color:#FFF; 
    position:absolute; // Add this 
    top:0; // to place it at the top 
    right:10px; //to place it extreme right at the offset of 10px 
} 

用於向右: 更改right爲0或任何優選值。

對於左:修改left

..和等