html文字段落宽度,html – 使兄弟元素采用相同的宽度打破其中的文本

如果我在这里没有完全弄错,那么使用CSS跨浏览器进行工作的唯一方法是将display:inline-block与display:table-row / display:table-caption结合起来.

堆栈代码段

.panel {

margin-bottom: 20px;

display: inline-block;

Box-shadow: 0 2px 4px 0 #C6C2BF;

padding: 0.5rem 1rem 1rem;

}

.user-title {

display: table-row;

}

.panel > div {

display: table-caption;

caption-side: bottom;

}

Date 08.03.2018 User: Joe Doe

Some long text in the paragraph that is wider than the title above it

Another shorter text

如果你不关心IE,那么使用width:0;最小宽度:100%;在.parent div.

注意,我在Edge v.16,Firefox v.58和Chrome v.64上成功测试了这一点,但是如果它适用于Safari我就不能说了.

堆栈代码段

.panel {

margin-bottom: 20px;

display: inline-flex;

flex-direction: column;

Box-shadow: 0 2px 4px 0 #C6C2BF;

padding: 0.5rem 1rem 1rem;

}

.panel > div {

width: 0;

min-width: 100%;

}

Date 08.03.2018 User: Joe Doe

Some long text in the paragraph that is wider than the title above it

Another shorter text

更新

经过一些反复试验,我在IE11和Edge / Firefox / Chrome上都有这个功能

堆栈代码段

.panel {

margin-bottom: 20px;

display: inline-flex;

flex-direction: column;

Box-shadow: 0 2px 4px 0 #C6C2BF;

padding: 0.5rem 1rem 1rem;

}

.panel > div {

width: 0;

min-width: 100%;

display: flex; /* for IE11 */

flex-wrap: wrap; /* for IE11 */

}

.panel > div > p {

flex: 100%; /* for IE11 */

}

Date 08.03.2018 User: Joe Doe

Some long text in the paragraph that is wider than the title above it

Another shorter text

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值