css问题将图像向下推
我在图像上方有一个文本段落。当段落变长并增加高度时,它会将下面的图像向下推。我怎样才能做到,如果段落的高度增加,下面的图像仍然保留其原始位置?
添加的代码:
img.alertIcon {
margin: 85px 0 0 15px;
float: right;
vertical-align: middle;
cursor: pointer;
visibility: visible;
clear: all;
}
#rightMain p {
width: 350px;
height: 100px;
background-color: #f7f7f7;
border-color: #ccc;
border-width: 1px;
border-style: solid;
float: left;
padding: 7px;
font-size: 14px;
margin: 0 0 10px 0;
}
I have a text paragraph above an image. When the paragraph grows and gains height, it pushes the image below down. How can i make it so that if the paragraph grows in height, the image below still retains its original position?
Added code:
img.alertIcon {
margin: 85px 0 0 15px;
float: right;
vertical-align: middle;
cursor: pointer;
visibility: visible;
clear: all;
}
#rightMain p {
width: 350px;
height: 100px;
background-color: #f7f7f7;
border-color: #ccc;
border-width: 1px;
border-style: solid;
float: left;
padding: 7px;
font-size: 14px;
margin: 0 0 10px 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
抱歉,如果我误解了您想要的内容,但也许可以让您的图像有一个固定的位置。 CSS 位置:固定。
如果您可以发布一个也会有帮助的示例。
Sorry if I misunderstand what you're wanting, but maybe make your image have a fixed position. CSS position: fixed.
If you could post up an example that'd help as well.
您可以尝试这个
position:fixed;
,如果它是背景background-position: center Bottom;
You can try this one
position:fixed;
and if it is backgroundbackground-position: center bottom;
我认为最好的方法是让图像浮动。
如果图像位于段落内,只需将
float: left
或float:right
添加到图像中,以便图像保持在同一位置I think the best way will be to have the image float.
if the image is inside the paragraph simply add the
float: left
orfloat:right
to the image so the image will stay in the same spot