I am striving to achieve a layout similar to this: https://i.sstatic.net/HIEB4.png
However, in Bootstrap, I am currently getting this: https://i.sstatic.net/sLw1v.png
My desired layout specifications are as follows:
- Width ratios should be in the proportion of
Sites : User : Download = 2:8:2
Sites-Banner
,Sites-Search
,Download-Banner
,Download-Summary
all need to have the same heightsUser-Login
must have a combined height equivalent to that ofSites-Banner
&Sites-Search
(orDownload-Banner
&Download-Summary
)- Heights of
Sites-List
,User-Operations
,Download-Details
must be independent and able to extend as needed.
Here is my code for reference: Fiddle (Please see Update 1)
<div>
<div class="row">
<div class="col-2">
<div class="row">
<div class="col bg-primary">
<p id="sites-banner">Sites Banner</p>
</div>
</div>
<div class="row">
<div class="col bg-secondary">
<p id="sites-search">Sites Search</p>
</div>
</div>
<div class="row">
<div class="col bg-success">
<p id="sites-list">Sites List</p>
</div>
</div>
</div>
<div class="col-8">
<div class="row">
<div class="col bg-danger">
<p id="user-login">User Login</p>
</div>
</div>
<div class="row">
<div class="col bg-warning">
<p id="user-operations">User Operations</p>
</div>
</div>
</div>
<div class="col-2">
<div class="row">
<div class="col bg-info">
<p id="downloader-banner">Download Banner</p>
</div>
</div>
<div class="row">
<div class="col bg-light">
<p id="download-summary">Download Summary</p>
</div>
</div>
<div class="row">
<div class="col bg-dark">
<p id="download-details">Download Details</p>
</div>
</div>
</div>
</div>
</div>
- I managed to align the height of
User-Login
withSites-Banner
&Sites-Search
[Completed: Update 1] Sites-List
,User-Operations
&Download-Details
do not extend independently
Update 1: New Code
- I was successful in setting the
User-Login
height to match the combination ofSites-Banner
&Sites-Search
, by enclosing them within a singlerow
- However, I still face difficulty in making the heights of
Sites-List
,User-Operations
,Download-Details
independent.
Update 2: New Code
- Managed to make the heights of
Sites-List
,User-Operations
,Download-Details
appear distinct. - However, there seems to be excessive padding between columns, causing misalignment and white space.
https://i.sstatic.net/2o8mL.png
Update 3: Fiddle
While it may seem in Update 2 that Sites-List
, User-Operations
& Download-Detail
vary in height, they actually do not. This illusion is due to only applying background-color classes to the enclosing div
element containing the list items.
https://i.sstatic.net/uH9Sn.png
To address the padding issue between columns, applying a mx-0
class attribute on the two rows will set the margin to zero.
By default, rows have a negative margin of -15px
.
Refer: Bootstrap negative margin on rows
If mx-0
is omitted, horizontal scrollbars may appear on the page. Refer: Bootstrap columns cause horizontal scrollbar
Key Points:
- Treat
row
&col
like Table'str
andtd
- Always place content within
col
- A
col
should always have a parentrow
. Refer: Bootstrap Grid Working & Guidelines