内容显示在div下方

时间:2015-01-20 12:26:26

标签: jquery html css

我有一个div,当你将鼠标悬停在它上面时,它旁边会出现一个相同的div。在这个悬停div中,我想提供有关你徘徊的div的更多信息。

我的问题是;内容显示在div下方,但具有样式(即边框半径和背景颜色)。

我的HTML:

        你需要悬停的div。

    <div id="tankinfo"><p class="info">Content what appears beneath the div.</p></div>

我的CSS:

.links{
    float: left;
    width: 250px;
    height: auto;
    margin-left: 135px;
    color: white;
}
.tank{
    height: 175px;
    width: 250px;
    padding: 5px;
    background-color: #CECECE;
    border-radius: 5px;
    float: right;
    margin-top: 75px;
    font-family: 'Open Sans';
    color: white;
    text-align: center;
}
#tankinfo{
    height: auto;
    width: 250px;
    padding: 5px;
    font-family: 'Open Sans';
    border-radius: 5px;
    margin-top: 75px;
    background-color: #CECECE;
    margin-left: 275px;
    color: white;
}
p.info{
    font-family: 'Open Sans';
    color: white;
    width: auto;
    height: auto;
    font-weight: 300;
    top: -5%;
    margin-left: 5px;
}

现在的情况图像; http://imgur.com/IiZvepx

编辑: 显示情况的图像:内联块; http://imgur.com/2240A6E

1 个答案:

答案 0 :(得分:0)

这不是问题,那就是div是如何工作的,它们是块级元素,所以它们会掉到另一条线上。

你的css中需要display:inline-block;让它们彼此相邻

相关问题