C
C
Cyril2018-04-13 00:07:06
css
Cyril, 2018-04-13 00:07:06

How to make the background of a web page in the form of a triangle?

There is a landing page PSD layout that has almost the entire background of a solid color. Let's say #fff colors.
But somewhere in the middle of this layout, there is a geometric figure in the background in the form of a wide inverted triangle. Moreover, the base of the triangle is directed to the site header, and the top to the site footer.
A simple background for a landing page is easy to draw. Like this:

html {
    background: #fff
}

But how do you define an inverted triangle with CSS? Putting it as an image is not an option. Is it possible to define a triangle with CSS style rules? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2018-04-13
@webinar

Putting it as an image is not an option

Why? png or svg will be extremely small. This is a great option.

S
Stalker_RED, 2018-04-13
@Stalker_RED

The triangle pseudo-element, and z-index: -1
But the body background must be transparent, otherwise you won't see what's underneath.
https://jsfiddle.net/dhy1xdcx/

S
SagePtr, 2018-04-13
@SagePtr

You can set gradients: https://codepen.io/SagePtr/pen/rdgeNP?editors=0100
(for example, gradients from yellow to red for clarity, but it is quite possible to replace from white to white, and the background will become uniform, but with a hole in the middle in the form of a triangle)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question