css - 如何防止文本移到列外?

标签 css twitter-bootstrap-3

在我的 reactjs 组件中,我在 render() 中返回这个:

<div className='col-lg-4'>
       <div className="col-lg-3">
            <img src={this.props.details.avatar} alt=""/>
       </div>
       <div className="col-lg-9 text">
       <div>
            {this.props.details.firstName}
            {this.props.details.lastName}
            {this.props.details.bio.slice(0,80)}
       </div>
    </div>
</div>

目前包含文字的this.props.details.bio溢出到图片中。哪个 css 规则可以解决这个问题?目前我有:

.text{
  padding:5px;
}

这是一个jsFiddle

最佳答案

图像的自然大小大于包含它的 Bootstrap 类。因此,看起来像是渗入图像的文本实际上是图像超出了其父级的边界。

要强制图像服从其父级的大小,请将此添加到您的 CSS:

img {
  width: 100%;
  height: auto;
}

关于css - 如何防止文本移到列外?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47483105/

相关文章:

javascript - 如何选择父标签?

html - 在具有内部渐变背景的CSS中生成具有可变尺寸的矩形

css - 为什么我的 webkit 渐变删除了我的 span 元素?

css - bootstrap 3 .nav 在 Internet Explorer 9 中的位置

html - Bootstrap 导航未居中

html - CSS定位: how to position a block/paragraph under another

javascript - 使用 jQuery 如何将页面中的相同 ID 更改为 Bootstrap 选项卡的序列化 ID

javascript - 使用下拉菜单操作 Bootstrap 导航,以便页面上始终显示 1 个下拉菜单

html - 使用 bootstrap 时 Logo 和 Facebook 链接图标未正确对齐

html - body 上带有线性渐变的背景图像未使用 Bootstrap 显示