2017-05-07 21 views
0

我不知道如何解決這個問題:圖像直接位於某些文本下方,並且在調整窗口大小時直接位於該文本下方。我的問題是我不能將圖像浮起來,它需要進一步出去,並用一些文本內聯。就像圖像居中一樣,即使在頁面大小調整的情況下,它也會始終保持在相對中心位置。如何在一個相對點上完全修復圖像css

編輯:我認爲這個問題是我有文字的3個部分彼此相鄰格式化這個樣子,和他們移動網頁時調整:

<!DOCTYPE html> 
<link rel="stylesheet" type="text/css" href="example.css"/> 
<p>this is the text which the image should follow (stay inline with) 
</p> 
<p>third section middle</p> 
<p>third section right</p> 
<img src="https://codepo8.github.io/canvas-images-and-pixels/img/horse.png"/> 

CSS:

p{ 
    float:left; 
    width:33.33333%; 
    text-align: center; 
    color: #2A3132; 
} 
img{ 
    width: 10%; 
} 

我希望圖片在頁面大小調整時保留在文本的中心。我希望這有幫助。

+1

問題尋求幫助的內部( 「**爲什麼不,或者如何讓這段代碼的工作?**」)必須包括期望的行爲,特定的問題或錯誤,以及在問題本身**中重現**的最短代碼。沒有**明確問題陳述**的問題對其他讀者沒有用處。請參閱:[如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 – LGSon

回答

0

投放父content

.content{ 
 
    background: yellow; 
 
    padding: 5px; 
 
    border: 1px solid red; 
 
} 
 
p{ 
 
    display: inline-block; 
 
    margin-right: -4px; 
 
    width:33.33333%; 
 
    text-align: center; 
 
    color: #2A3132; 
 
    background: red; 
 
    vertical-align: top; 
 
} 
 
img{ 
 
    display: block; 
 
    margin: 0 auto; 
 
}
<div class="content"> 
 
    <p>this is the text which the image should follow (stay inline with)</p> 
 
    <p>third section middle</p> 
 
    <p>third section right</p> 
 
    <img src="http://devimg.com/100x100/"/> 
 
</div>

相關問題