css percentage based background

arahant

How can I show a div with some text (which fills the div completely in width) and then show a background color which is only 40%, without obstructing the text.

The following is problematic because the text is within the inner div. I want it in the outer div so to speak.

<div>
<div style="background-color:#EAFEE2; width:35%;"><span>This is a much longer text and takes up a lot of space</span></div>
</div>

Alireza

You can use gradiant background .

background:linear-gradient(90deg, #EAFEE2 40%, #FFFFFF 50%)

check this link for More information: CSS: Set a background color which is 50% of the width of the window

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related