html - 边框底部的位置标题

标签 html css

我正在尝试创建具有响应能力的宝丽来外观相框。 问题是标题不会粘在底部边框上,它只是浮​​在图像上。

如果我使用像素而不是百分比,它可以工作,但不是其他方式。 有什么想法吗?

the fiddle

HTML

<div class="imageContainer">
  <img src="http://photogallery.indiatimes.com/beauty-pageants/miss-india/rochelle-maria-raos-photo-shoot/photo/16651703/Miss-India-International-Rochelle-Maria-Rao-during-her-photo-shoot-.jpg" />
    <p> Title</p>
</div>

CSS

.imageContainer {
    position: relative;
    width: 25%;
    padding-bottom: 25%;
    float: left;
    height: 0;
    margin-right:10px;
    border:10px solid #e3e3e3;
    border-bottom:30px solid #e3e3e3;
}

.imageContainer img {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
}
.imageContainer p{
    position:absolute;

}

最佳答案

你在做什么是不正确的,你在图像周围使用了粗边框,这会阻止内部文本流过它,为了实现这一点,你需要为你的 bottom 使用负值标题

.imageContainer p{
    position:absolute;
    bottom: -40px;
}

Demo

我建议您使用 display: inline-block; li 元素和嵌套的 div & img 而不是这种方法 标签,div 具有固定的高度和 img 具有固定的 min heightwidth 您的标题元素位于 absolute at bottom 0

关于html - 边框底部的位置标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17673684/

相关文章:

javascript - 即使在页面重新加载后也显示 div

php - 如何根据单选按钮显示和隐藏字段

python - 在 Python 中从复选框中提取表单数据

javascript - 检测用户是否未输入任何内容/删除输入 jQuery

html - 元素没有正确 float

html - 为什么我的网站底部有多余空间?

css - Chrome (+FF) 显示奇怪的重复 CSS

ios - JQuery Mobile : Extra space, 黑线出现在数据角色 ="content"下?

javascript - primefaces codeMirror不加载自己的css和js

html - 我无法让背景图像显示在 Internet Explorer 上