I am currently in the process of developing a website that showcases various pages detailing fictional characters and locations. These pages are divided into categories, each featuring a profile box containing a heading, an image, and a summary table.
Here is an example of the HTML structure for such a box:
<profilebox class="red">
<p><i>His Majesty</i><br><span class="big-and-strong">The King</span>
</p>
<figure class="pbox"><img class="pbox" src="../images/armsroyal.svg">
</figure>
<table class="pbox">
<tr>
<td>Surname</td>
<td>N/A</td>
</tr>
<tr>
<td>Forename</td>
<td>N/A</td>
</tr>
<tr>
<td>Rank</td>
<td>King</td>
</tr>
<tr>
<td>Addressed As</td>
<td>‘‘Your Majesty’’</td>
</tr>
</table>
</profilebox>
The corresponding CSS code looks like this:
profilebox {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 1em;
margin-right: 0em;
width: 400px;
float: right;
text-align: center;
padding: 1em;
border-color: black;
border-style: solid;
border-width: 0px 0px 0px 5px;
}
table {
border-collapse: collapse;
width: 600px;
}
.mini {
width: 400px;
}
.maxi {
width: 100%;
}
.pbox {
width: 100%;
}
img {
margin: 1em;
}
.pbox {
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
}
figure.pbox {
width: 100%;
}
It was expected that setting the width of the pbox
class to 100% would make the table fill its parent element. However, when viewed in Chromium, the table appeared too narrow:
Replacing
<table class="pbox">
with <table class="maxi">
resulted in the desired outcome:
Interestingly, the maxi
and pbox
classes of the table are actually identical! Can anyone shed some light on what might be causing this discrepancy?