Reputation: 20282
I have a table like this which i created with div's. However, if a text is too long, then all the cells from this row will be filled with white background color.
* {
word-break: break-word;
}
div {
display: block;
border: 1px solid black;
}
.main_div {
background-color: #D8D8D8;
}
.row {
margin-left: 0px;
margin-right: 0px;
}
p {
display: inline;
}
#verzeichnis {
text-align: center;
}
.tabelle {
background-color: #AAAAAA;
border: 1px solid black;
}
.test {
background-color: #D8D8D8;
}
<div class="row">
<div class="col-sm-12 tabelle">
<p id="verzeichnis"> Test 1 </p>
</div>
<div class="row">
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p id='Datei' class="dateiname_h" style="display:inline"> File <i id="dateiname_h_icon" class='fa fa-toggle-on pull-right'></i></p>
</div>
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p>A</p>
</div>
<div class="col-sm-3" style="background-color: #A4AfA4;">
<p>Status</p>
</div>
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p>B</p>
</div>
</div>
<div class="row">
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p id='Datei' class="dateiname_h" style="display:inline"> short text </p>
</div>
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p>short text</p>
</div>
<div class="col-sm-3" style="background-color: #A4AfA4;">
<p><span style='color:green'><i class='fa fa-check-circle-o'></i></span></p>
</div>
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p>very long text which should break to the next line because word wrap is set to break-word</p>
</div>
</div>
<div class="row">
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p id='Datei' class="dateiname_h" style="display:inline"> File <i id="dateiname_h_icon" class='fa fa-toggle-on pull-right'></i></p>
</div>
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p>A</p>
</div>
<div class="col-sm-3" style="background-color: #A4AfA4;">
<p>Status</p>
</div>
<div class="col-sm-3" style="background-color: #D8D8D8;">
<p>B</p>
</div>
</div>
</div>
NOTE: stackoverflow does not seem to understand bootstrap, even though i included it as external library into my snippet. This is how it should look if you run the snippet:
My goal is to remove the white gap so it looks like this.
Upvotes: 0
Views: 92
Reputation: 7783
I would have used a real table for tabular data. Anyway, you can use CSS display:table
for a workaround.
Parent:
.row {
margin-left: 0px;
margin-right: 0px;
display:table;
width:100%;
}
Children:
.row .col-sm-3 {
display:table-cell;
float:none;
}
I would suggest applying this CSS to to a specific container to minimize messing with bootstrap's default styling, like .customTable .row
and .customTable .row .col-sm-3
Upvotes: 3