html - 内部图片的分割宽度

标签 html css twitter-bootstrap

我希望文字不要大于图片,这里是问题的一个例子

http://i.imgur.com/DwIMS3Q.png

我希望它变成什么样

http://i.imgur.com/VOA1W60.png

如您所见,当图片太紧时,由于文字的缘故,会出现白色边框。我希望文字不要比图片大。

这是 HTML 代码:

<div class="row">
    <div class="col-md-6" style="float:none;margin:0 auto;">
        <div class="polaroid center-block">
            <img src="./images/650x650.png" alt="Norway" class="img-responsive center-block" style="width:auto;height:auto">
            <div class="my_container" style="width:auto;height:auto">
                <p>The Troll's in Hardanger, Norway</p>
            </div>
        </div>
    </div>
</div>

这是 CSS:

body {
    margin: 25px;
}

div.polaroid {
    background-color: white;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    margin-bottom: 25px;
}

div.my_container {
    text-align: center;
    padding: 10px 20px;
}

提前致谢。

最佳答案

将图像的宽度设置为 100%。

.polaroid img{
    width: 100%;
}

还有宝丽来:

.polaroid {
    width: 100%;
}

关于html - 内部图片的分割宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44139802/

相关文章:

html - 缩小页面时扭曲的菜单栏

将数据保存在全局变量中的javascript函数

jquery - Bootstrap 进度条 : add to the css: width value, 全部在 coffeescript/jQuery 中

html - 谷歌浏览器不呈现背景色

jquery - 动态显示表格行和 CSS 奇数/偶数匹配

HTML 复选框 - 只允许勾选一个复选框

html - webkit 浏览器上的悬停问题

javascript - 按钮点击只有效一次

Css 文本段落对齐

jquery 覆盖我的 css 颜色