When a client approached me and wanted a slanted div overlay on the homepage, I knew straight away it would have to be built in CSS. Why? Because the overlay his graphic designer built into the image, did not display correctly on devices. The text was completely unreadable.
So I went searching the deep dark corners of the internet for a slanted DIV overlay, and I found this awesome article. Nils explains it in a much cooler way than me, and has awesome graphics to match, so I won’t go into detail here. Regardless I am sharing the code I used to implement this on a WordPress site and you are welcome to cut and paste it into your next project.
Step 1.
First I cloned Nils pen on Codepen, and added the code from the article. Now with the code he provided, as soon as I dumped it into WordPress it did not display the same. I had to modify it heavily to get the look I wanted. Mostly because he was using the transform:skewY property, and for this project I need to use transform:skewX. That and I needed multiple media queries to work with WordPress. I started with the overlay, and then made some design decisions on how wide I wanted it to be. It had to be wide enough to cover roughly half the image, and comfortable display the text inside it, but not so wide that it don’t go all the way to the edge of the screen.
Step 2.
Then I added my text into the heading tags, and added a default margin for a wide screen. Because we are using the transform:skewX() property, everything inside the DIV is going to skew including the text. We don’t want this. Here’s an example of the ugliness that skewed text is, check out this H2 element:
Step 3.
I added the transform:skewX() property to each heading element. Since the overlay has a property of transform:skew(200.25deg), we have to apply transform: skewX(-20deg) to each heading element to ensure the headings are upright.
Step 4.
I started working on the media queries to make the page look responsive on all devices. This was a tad painful, as I had to keep tweaking the elements and overlay to get the right balance, but I got there. Now mind you if you view the Codepen, and it doesn’t look right on devices- this code has been used on a live wordpress site, so the responsive widths work on WordPress but they will not work on Codepen. Click here to view the source code.
Alpha Omega Digital is a WordPress web development agency based in Melbourne, Australia but also services clients from Sydney, Brisbane, Newcastle, Perth, Adelaide, Darwin and Hobart.
JamesBuins says
gates of olympus автомат gates of olympus slot
mostbet_680 says
рабочий промокод мостбет 2024 промокод мостбет как пользоваться 2024
DavidPhist says
Online casino https://pacificentertainment.biz/2024/10/06/1win-nigeria-how-to-start-betting-today with high bonuses, roulette and slots, instant payouts. Register on the official mirror.
Vivod iz zapoya rostov_niel says
клиника вывод из запоя ростов клиника вывод из запоя ростов .
Narkolog na dom krasnodar_maEl says
нарколог на дом цены нарколог на дом цены .
Vivod iz zapoya rostov_byPl says
срочный вывод из запоя ростов срочный вывод из запоя ростов .
Armandoktoort says
Как поднять себе настроение? Почитайте
прикольные анекдоты и поделитесь с близкими.
AndrewWrato says
lucky jet официальный сайт лаки джет онлайн
Gartandcax says
ржачные картинки. Как они появились.
DouglasQuore says
The Best Promo Code for 1xBet https://idematapp.com/wp-content/pages/1xbet_promo_codes_free_bonus_offers.html
The best promo codes for 1xBet are those that offer significant bonuses, such as large deposit matches, free bets, or free spins. These codes can greatly enhance the betting experience by providing extra value for users.
Xjoaju says
order flagyl sale – order metronidazole 200mg for sale buy cenforce 100mg for sale
Sheldonhiect says
Авиатор игра на деньги Авиатор бонусы
JamesitarF says
helium balloons price buy inflatable balloons