0

I am trying to make the background less opaque but have the colour of the text remain the same.

.overview {
  background: gray;
  width: 45%;
  opacity: 0.3;
  margin-left: auto;
  margin-right: auto;
  font-size: large;
  border-radius: 8px;
}

.overview p {
  text-align: center;
  color: white;
}
<div id="overview" class="overview">
  <p>
    Blah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blah Blah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blah

  </p>
</div>

However both the text and background colour become dimmer

Smollet777
  • 1,618
  • 1
  • 16
  • 15
wtreston
  • 1,051
  • 12
  • 28

2 Answers2

4

Your background should be an RGBA color, applying opacity is for the div

background-color:rgba(128,128,128,0.3);
Nickfmc
  • 369
  • 1
  • 8
0

@wtreston The following code should be:

.overview {
    background: gray;
    width: 45%;
    opacity: 0.3%;
    margin-left: auto;
    margin-right: auto;
    font-size: large;
    border-radius: 8px;

}

.overview p {
    text-align: center;
    color: white;
}
<div id="overview" class="overview">
        <p>
                Blah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blah
                Blah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blahBlah blah

        </p>
    </div>

I may have misunderstood your question.

Hope This helps!