How can I solve this?

Edit: its best if you paste the code in your code editor. you can see that I am able to make it so that it changes the color to green when you hover over it. the problem is that it takes up the entire width.

Hello, beginner programmer here. I am just learning css and I decided to make a project with the css function linear-gradient(). Though I was able to achieve what I wanted, I cant make the div not take up the entire width of the screen. I learned how to do it back when I started but eventually forgot.

ik this question is dumb but I just need to learn how can I achieve this. any help would be greatly appreciated.

        background-color: rgb(171, 236, 20);    

    /* 171 236 20 */
<div class="test">
        Lorem ipsum dolor sit amet.



How wide do you want the div.

You can use the width property, using div as the selector. A good idea is to use percentage or view width units to make the element responsive.

Happy coding

1 Like