JSFiddle - React, Tailwind, and code Playground
by Spencer Wasden
HTML
<div class="fade-out-container">
<div class="mask text-nowrap">
short text asdf sad sdf asdfsds sad sds af sadf sdfsda
</div>
</div>
CSS
.fade-out-container{
/* position: absolute; */
overflow: hidden;
/* width: 300px;
height: 150px; */
border: 1px solid gray;
}
.text-nowrap{
white-space: nowrap;
}
.mask {
position: relative;
width: 100%;
height: auto;
padding: 2px;
background-color: transparent;
background-image: -moz-linear-gradient(left, #FFFFFF 85%, rgba(208, 208, 211, 0.3) 99%);
background-image: -webkit-linear-gradient(left, #FFFFFF 85%, rgba(208, 208, 211, 0.3) 99%);
background-image: -o-linear-gradient(left, #FFFFFF 85%, rgba(208, 208, 211, 0.3) 99%);
background-image: linear-gradient(to right, #FFFFFF 85%, rgba(208, 208, 211, 0.3) 99%);
/*filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='[color]', endColorstr='[color]', GradientType=1);*/
}
.mask:after {
content: '';
position: absolute;
z-index: 2;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: transparent;
background-image: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 85%, rgba(255, 255, 255, 1) 99%);
background-image: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 85%, rgba(255, 255, 255, 1) 99%);
background-image: -o-linear-gradient(left, rgba(255, 255, 255, 0) 85%, rgba(255, 255, 255, 1) 99%);
background-image: linear-gradient(to right, rgba(255, 255, 255, 0) 85%, rgba(255, 255, 255, 1) 99%);
/*filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='[color]', endColorstr='[color]', GradientType=1);*/
}