Being a web designer / web developer, you are faced with the task of translating designs a graphic designer’s has created for a project you are working on into code. Since this is not a task of just eyeballing what you see and making visual approximations, you sometimes have to dive deep into some tools that you do not normally work with to complete the task.
Say you are tasked with taking the following design and making a webpage with the exact same colors and it is presented to you as a power point design.
Assuming basic html knowledge, the following is a basic html template with bootstrap included as well as a custom css file where we will edit the colors
|<!-- Required meta tags -->|
|<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">|
|<!-- Bootstrap CSS -->|
|<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">|
|<!-- Linking Our Custom main.css file -->|
|<link rel="stylesheet" type="text/css" href="main.css">|
|<div class="container mt-5">|
|<div class="card py-4">|
If you open the index.html file in a browser immediately after adding the above template it will contain a basic white block , but that certainly wont make the designer happy.
What we want is the block to to look just as it did in the design as far as the gradient is concerned, and we cannot simply take an eye measurement. Fortunately we know about https://cssgradient.io/. Visiting the website we see the following.
Css gradient is a visual tool that allows to us to convert RGB values into css code that we can use in our css file. All that is need now is to find the exact RGB values sent over by the designer in the power point file. Here is how . .
Follow these steps in order
1. Select the shape you want to extract colors from.
2. Above the toolbar to the right find and click on “Shape Format”
3. In the toolbar section on the far end click on “Format Pane”
4. Under the the tab “Shape options ” expand the section “Fill” and select the “Gradient fill” radio button if not already selected
5. Still under “Gradient options” , locate “Gradient stops”, click on the first gradient stop and the click the color bucket next to the “Color ” heading
6. Click on more colors
You will end up with the following window
In https://cssgradient.io/ copy the the RGB values over from power point as well as the opacity value and map it to the corresponding gradient stop.
Do the same for the second gradient stop, steps (5 – 6 ) above and you should end up with something like this in https://cssgradient.io/
the exact same gradient as in the design. However what we are really interested in is the css part at the bottom.
Copy it into your clipboard and paste into your main.css file under the “.card” class which is the same class that references the white block we currently have in our html file.Here is the result . .
Notice I have added a border-radius: 0 to remove the rounded edges.
Now opening the index.html file in the browser again we should see the following . .
Here is the original design once again
We have successfully recreated the design sent to us with the exact colors using html and css 😎