2017-05-07 45 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>