html - css 禁用/空行而不使用显示 : none

标签 html css layout

我有一系列用于以表格方式显示数据的 div。

这是我目前拥有的:

enter image description here

但这就是我试图通过更改 css 来实现的:

enter image description here

我无法更改 HTML(即 <.div.class='row'.> 必须保留在原位),因为 HTML 框架用于其他不同的 css 样式。

我在调整 css 时遇到问题,因为我不确定如何将 css 应用到 <.div.class='row'.> 以便实现我需要的显示(如果我删除行 div,我想要的显示已实现)。我尝试了很多方法,但对我没有任何作用。

是否可以更改类行以便实现所需的显示(如上所示)?或者我应该实现单独的 HTML 代码来解决这个问题吗?我想我应该问一下,因为这会节省很多时间和精力 - 只是不确定是否可以完成。

这是我的 HTML 代码:

    .wrapper{
        border-spacing: 1px 1px;
        display: table;
        width: 100%;
    }
    
    .row{
        display: table-row;
    }
    
    .heading {
        display: table-cell; 
        width: 18%; 
        background-color: #000; 
        color: #fff; 
        font-weight: bold; 
        vertical-align: top;
    }
    
    .content {
        display: table-cell; 
        width: 98%; 
        padding: 2px; 
        vertical-align: top;
    }
 <div class="wrapper">
        <div class="row">
            <div class="heading">SUMMARY</div>
        </div>
        <div class="row">
            <div class="content">
                This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details.<br /><br />
                This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details. This is a test of the summary details.
            </div>
        </div>
    </div>

最佳答案

fiddle :http://jsfiddle.net/6vote8pz/1/

您需要将 display:table-cell 添加到行中:

.row{
    display: table-cell;
    vertical-align:top;
}

关于html - css 禁用/空行而不使用显示 : none,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30556107/

相关文章:

jquery - 将div悬停在另一个图标中触发动画效果

android - 布局中的布局android

python - 从布局中删除所有项目

java - Jsoup 从 div 的子级中抓取文本

css - 垂直菜单响应

php - 发布输入类型文件问题 未发布任何值

html - 使用CSS水平居中菜单按钮

Android更改默认按钮背景颜色

html - float :left in a div not working as expected

css - 网站在某些页面上向右滚动