2017-07-07 64 views
0

我有一個僞類:之前與背景圖像300x200px和CSS的內容:「」是背景的名稱,應該定位在右下角:之前與圖像和內容:「」的內容在右下角

我用

text-align:right; 

,並用於填充的把文本往下但炸燬元素的高度,所以我需要這樣的一個其他的解決辦法。不,我不能爲文本使用單獨的元素。

編輯:我不能顯示的代碼,因爲它是一個版(Subreddit)樣式表,並有更多的CSS那麼我可以告訴

#header [name='uh']~a:before, body>.side:before { 
position: absolute; 

width: 298px; 
content: ''; 
text-align: right; 
padding-top: 375px; 
padding-right: 2px; 
color: rgba(64, 92, 120, 0.7); 
top: -207px; 
right: -300px; 
background-size: contain; 
background-repeat: no-repeat; 
background-position: center; 
} 

body>.side:before { 
top: 70px; 
z-index: 100; 
top:-200px; 
right:0; 
} 
#header [name='uh'][value$='0'] ~ a:before { background-image: url(%%1%%); content: '/u/Hisfantor';} 
+6

你能提供你的代碼爲好,並更新你的答案。這很難遵循,而且根本不明確。謝謝! –

+0

我同意Hisfantor。很難理解你想要達到的目標。如果您提供代碼,我們可能能夠確定問題。 –

+0

我無法顯示代碼,因爲它是用於subreddit樣式表,並且還有更多的css,然後我可以顯示 – Hisfantor

回答

0

你可以使用line-height屬性的

查看下面的代碼片段,使用CSS和HTML。

.test { 
 
    position: relative; 
 
    height: 300px; 
 
} 
 

 
.test::before { 
 
    content: "image"; 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    bottom: 0; 
 
    margin: auto; 
 
    height: 300px; 
 
    width: 300px; 
 
    text-align: right; 
 
    line-height: 600px; 
 
    background-image: url("https://hub.91mobiles.com/wp-content/uploads/2016/09/Google-Now-launcher.png"); 
 
}
<div class="test"></div>

Link for reference

我希望這有助於..

+0

,感謝您的想法 – Hisfantor