I need the table to have a transparent bottom and a clear top for better readability.
Here is my attempted solution:
.preview {
background: -moz-linear-gradient(top, rgba(255,255,255,0) 25%, rgba(255,255,255) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(25%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255)));
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0089fff1', endColorstr='#000000',GradientType=0 );
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 150px;
transition: all 0.3s;
}
<table>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
</table>
<div class="preview"></div>
The above code works as intended. However, adding content before the table causes issues.
.preview {
background: -moz-linear-gradient(top, rgba(255,255,255,0) 25%, rgba(255,255,255) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(25%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255)));
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,0) 25%,rgba(255,255,255) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0089fff1', endColorstr='#000000',GradientType=0 );
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 150px;
transition: all 0.3s;
}
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Libero, et, cumque. Explicabo consectetur accusamus enim aspernatur veritatis facilis dolores ex necessitatibus beatae aliquam voluptatem debitis eaque neque, consequatur dolorem tenetur! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Expedita amet sequi, velit inventore aliquid in dicta ipsum fugiat recusandae iusto distinctio commodi est, asperiores neque hic consequuntur minima, sapiente numquam? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem nobis ex soluta eos deleniti, explicabo repellendus repellat rem aliquam quibusdam. Quo, qui, magni! Aperiam illum similique, id, dolor tenetur qui!
<table>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
</table>
<div class="preview"></div>
The issue arises due to the usage of position: absolute
within the preview
class. Let's explore a better approach to achieve the desired outcome.