2

I have a div container that contains text-boxes when some of them are overflowing.
I'm trying to create a white blur in css like in this example:

blur sample

My goal that the blur will be from the bottom:

blur sample

I've tried this example, but its not working for me.
Any help will be appreciated

I created a Fiddle with my status.

.container {
  margin-top: 10px;
  border: 1px solid grey;
  width: 200px;
  height: 60px;
  overflow: hidden;
}

.text-box {
  padding: 2px;
  display: inline-block;
  border-radius: 5px;
  color: #fff;
  background-color: blue;
  height: 25px;
  margin: 5px;
  font-size: 12px;
  line-height: 25px;
}
<div class="container">
  <div class="text-box">
    Some text
  </div>
  <div class="text-box">
    Some text
  </div>
  <div class="text-box">
    Some text
  </div>

  <div class="text-box">
    Some text
  </div>

  <div class="text-box">
    Some text
  </div>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Igor.R
  • 175
  • 4
  • 14

2 Answers2

3

This will do:

.container {
  margin-top: 10px;
  border: 1px solid grey;
  width: 200px;
  height: 60px;
  overflow: hidden;
  position: relative;
}

.container:after {
  content: '';
  position: absolute;
  left: 0px;
  right: 0px;
  height: 50%;
  bottom: 0px;
  background: linear-gradient(180deg, rgba(139,167,32,0) 0%, rgba(255,255,255,1) 100%);
  pointer-events: none;
}

.text-box {
  padding: 2px;
  display: inline-block;
  border-radius: 5px;
  color: #fff;
  background-color: blue;
  height: 25px;
  margin: 5px;
  font-size: 12px;
  line-height: 25px;
}
<div class="container">
  <div class="text-box">
    Some text
  </div>
  <div class="text-box">
    Some text
  </div>
  <div class="text-box">
    Some text
  </div>

  <div class="text-box">
    Some text
  </div>

  <div class="text-box">
    Some text
  </div>
</div>
MaZoli
  • 1,388
  • 1
  • 11
  • 17
1

I hope this can help you.

.container {

  position: relative;
}

.text-box {
  padding: 2px;
  display: inline-block;
  border-radius: 5px;
  color: #fff;
  background-color: blue;
  height: 25px;
  margin: 5px;
  font-size: 12px;
  line-height: 25px;
}

.container-scroll {
    margin-top: 10px;
  border: 1px solid grey;
  width: 200px;
  height: 60px;
  position: relative;
  overflow-y: auto;  
}
 .wrapper {
 pointer-events: none;
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
    background: rgb(255,255,255);
    background: -moz-linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 77%);
    background: -webkit-linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 77%);
    background: linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 77%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff",endColorstr="#ffffff",GradientType=1);
  }
<div class="container">
<div class="container-scroll">
  <div class="text-box">
    Some text
  </div>
   <div class="text-box">
    Some text
  </div>
   <div class="text-box">
    Some text
  </div>
  
   <div class="text-box">
    Some text
  </div>
  
   <div class="text-box">
    Some text
  </div>
     <div class="text-box">
    Some text
  </div>
  
   <div class="text-box">
    Some text
  </div>
     <div class="text-box">
    Some text
  </div>
  
   <div class="text-box">
    Some text
  </div>
     <div class="text-box">
    Some text
  </div>
  
   <div class="text-box">
    Some text
  </div>
  </div>
  <div class="wrapper"></div>
  
</div>
Alberto Rhuertas
  • 733
  • 4
  • 12