好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CSS实现三栏布局中间一栏自适应且随文字大小变化宽度的示例代码

百度 面试碰到的题,要实现如下布局效果

其中中间这紫色的一栏的大小随字体的多少而变 宽 /变窄,且多出的文字自动省略为[ .. .], 右边 的绿色栏要紧紧连着紫色这一栏。 主要对紫色这一栏的操作为:

1.flex: 0 1 auto (自适应)

2.text-overflow:ellipsis;(自动省略文字)

overflow:hidden;

wh IT e -s pace: nowra p;

完整的代码如下

// CSS 部分
.cont ai ner {
  dis play : flex;
}
.pic {
  width: 100px;
  h ei ght: 100px;
  border-radius: 50%;
  background-color: pink;
}
.n am e {
  flex:0 1 auto;
  height: 100px;
  background-color: purple;
  text-overflow:ellipsis;
  overflow:hidden;
  white-space: nowrap;
}
.tag {
  width: 100px;
  height: 100px;
  text-align:  center ;
  line-height: 100px;
  background-color: seagreen;
}

// HT ML  部分
<div class="container">
    <div class="pic"></div>
    <div class="name">
        zhasansn DF dkfnald
    </div>
    <div class="tag">设计师</div>
</div>

总结

到此这篇关于CSS实现三栏布局中间一栏自适应且随 文字大小 变化宽度的示例代码的 文章 就介绍到这了,更多相关css三栏布局内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!

总结

以上是 为你收集整理的 CSS实现三栏布局中间一栏自适应且随文字大小变化宽度的示例代码 全部内容,希望文章能够帮你解决 CSS实现三栏布局中间一栏自适应且随文字大小变化宽度的示例代码 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于CSS实现三栏布局中间一栏自适应且随文字大小变化宽度的示例代码的详细内容...

  阅读:22次