I have a <h2>
tag above a <table>
and a @media (max-width: 1500px)
in my css file.
When the screen is small, the table overflows from its div, popping out further than the elements above. This is fine.
My problem is that Id like the <h2>
above it to match the width of the table.
Please see the image for clarification.
html
<div id="notifications">
<h2 class='notifications_heading'>Notifications</h2>
<table class='notifications_table'>
{% for notification in queryset %}
<tr>
<td>{{ notification.actor }}</td>
<td>{{ notification.verb }}</td>
<td>{{ notification.timestamp|date }}</td>
</tr>
{% endfor %}
</table>
</div>
css
#notifications {
float: right;
width: 500px;
position: relative;
margin-right: -840px;
}
@media (max-width: 1500px) {
#notifications {
float: right;
width: 260px;
margin-right: -290px;
margin-top: 290px;
}
}
.notifications_heading {
background: #79aec8;
}
.notifications_table {
width: 100%;
}
https://i.stack.imgur.com/FVKXN.jpg
Thank you.
``` still didnt match the table when I resized the window. Thanks a lot for your suggestion though :)
– horse Jun 11 '20 at 08:10