HTML Academy
Sharp Color Transitions
Linear Gradients10/23
Back to the list of tasks
  • 1. Hello, linear-gradient!
  • 2. Gradient Direction
  • 3. Diagonal Gradients
  • 4. Gradients at an Angle
  • 5. Diagonals vs. Degrees
  • 6. Challenge: Application Icons
  • 7. Uniform Multicolor Gradient
  • 8. Color Proportions and Color Stops
  • 9. Sharp Color Transitions
  • 10. Pseudo-Columns on Gradients
  • 11. Challenge: Flags
  • 12. Color-Stop Positions in Pixels
  • 13. Semi-Transparent Gradients
  • 14. Repeating Linear Gradient
  • 15. Creating a Complex Background – Part 1
  • 16. Creating a Complex Background – Part 2
  • 17. Creating a Complex Background – Part 3
  • 18. Let’s Create a Complex Background – Final Step
  • 19. Buttons – Part 1
  • 20. Buttons – Part 2
  • 21. Buttons – Part 3
  • 22. Challenge: Ornament Made of Shurikens
  • 23. Challenge: Satellites
Challenge: Flags
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Pseudo-Columns on Gradients

One of the more interesting challenges of creating a layout is: how can we lay out columns so that they extend to the same height without using tables? This problem is related to the behavior of the floated columns in this example, and it is illustrated in the images below:

The problem has to do with the behavior of the blocks in the layout.Desired behavior of blocks in the layout

There are several techniques for solving this problem, which are described in this article. By the way, we also borrowed these images from that article.

Let’s apply a gradient trick with sharp transitions that simulate stretched columns. Backgrounds that utilize these types of gradients are usually placed in a container of columns. The proportions of the gradients are selected to match the proportions of the columns so that their backgrounds appear to extend to the same height.

The effect shown in the assignment can be more easily achieved with flexbox.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Pseudo-Columns on Gradients</title> <meta charset="utf-8"> <link rel="stylesheet" href="setting.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container columns"> <div class="left"> <p>In the left column, the text has one length, and in the right column, the text has a different one. In this floated layout, neighboring blocks do not automatically match each other’s height, so they will not be equal in height. This is one of the shortcomings of using floats for columns.</p> </div> <div class="right"> <p> But you can insert a background behind them that uses the same colors as the columns to create the illusion that the columns are equal in height.</p> </div> </div> </body> </html>
CSS
body { font-family: "PT Sans", sans-serif; } .columns { background-image: none; } .container { margin: 20px auto; min-height: 380px; width: 300px; box-shadow: 1px 1px 3px #333333; color: white; } .container::after { display: table; clear: both; content: ""; } .left { float: left; width: 45%; background-color: #e74c3c; } .right { float: right; width: 45%; background-color: #3498db; } p { margin: 10px 0; padding: 0 10px; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. For .columns, set a linear left to right gradient with six colors: #e74c3c, #e74c3c, transparent, transparent, #3498db, #3498db. Yes, the colors are repeated two times.
    2. Then assign the position 45% to the second and third colors as well as 55% to the fourth and fifth colors.
    3. Then increase the width of .container to 400px,
    4. And finally, add the columns class to body.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2026

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.