css - div 表格单元格和溢出不起作用

标签 css

为什么这个溢出不起作用?

http://jsfiddle.net/kacx4kad/

<div class="table">
    <div class="table_row">
        <div class="table_cell">
            wee<br>wee<br>wee<br>wee<br>wee<br>wee<br>wee<br>wee
        </div>
    </div>
</div>

.table {
    display:table;
    width:100%;
}

.table_row {
    display:table-row;
}

.table_cell {
    position:relative;
    display:table-cell;
    vertical-align:top;

    background:red;
    height:50px;
    max-height:50px;
    overflow:hidden;
}

最佳答案

查看您的代码结构,您需要显示属性值 inline-block for .table_cell for the overflow 值生效。否则,您将不得不改变周围的事物。

.table {
	display:table;
	width:100%;
}

.table_row {
	display:table-row;
}

.table_cell {
	position:relative;
	display: inline-block;
	vertical-align:top;
    
    background:red;
    height:50px;
    max-height:50px;
    overflow:hidden;
}
<div class="table">
    <div class="table_row">
        <div class="table_cell">
            wee<br>wee<br>wee<br>wee<br>wee<br>wee<br>wee<br>wee
        </div>
    </div>
</div>

关于css - div 表格单元格和溢出不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28200074/

相关文章:

ipad - html5/css3、Asp.net MVC3 - 在移动 safari 上的 html 页面中查看 pdf

css - 在 Bootstrap 中选择具有表单宽度的列表

html - 重写这段代码 : clickable divs

css - 水平菜单合理定位元素

jquery - 如何制作这种形状奇特的幻灯片?

SelectionCell 的 CSS 样式

c# - 占位符外的母版页内容

javascript - -webkit-transition 在使用 jQuery 进行转换时无效

javascript - 即使我正在使用 focus(),列表项也没有获得焦点

html - 居中按钮和边框之间的间隙