Tuesday, January 7, 2020

How to Apply CSS3 Transforms to Background Images

How to Apply CSS3 Transforms to Background Images

CSS transformations are great, but they don't (yet?) apply to background images. This article presents a workaround for those times when you really do want to rotate a background image, or to keep a background image fixed while its container element is rotated.

This article was updated in 2020.

Scaling, skewing, and rotating any element is possible with the CSS3 transform property. It's supported in all modern browsers without vendor prefixes.

#myelement {
  transform: rotate(30deg);
}

Great stuff. However, this rotates the whole element — its content, border and background image. What if you only want to rotate the background image? Or what if you want the background to remain fixed while the content is rotated?

There’s no W3C CSS proposal for background-image transformations. It would be incredibly useful, so perhaps one will appear eventually, but that doesn't help developers who want to use similar effects today.

One option would be to create a new background image from the original, say rotated by 45 degrees. This could be achieved using:

  1. a server-side image manipulation process
  2. a client-side canvas-based image handling code, or
  3. APIs provided by some image-hosting CDN services.

But all these require additional effort, processing, and costs.

Fortunately, there’s a CSS-based solution. In essence, it's a hack which applies the background image to a ::before or ::after pseudo element rather than the parent container. The pseudo element can then be transformed independently of the content.

The post How to Apply CSS3 Transforms to Background Images appeared first on SitePoint.


by Craig Buckler via SitePoint

Pantheone Audio

Pantheone Audio
Pantheone products are designed by a team who share an uncompromising commitment to hand-crafted quality, design and engineering that breathes music into any living space.
by via Awwwards - Sites of the day

Mind Games Are Very Popular but are they Effective?

Over the years we have seen a tremendous increase in life spend with the help of medication and diet. As the gaining population increasing, maintaining good health in older days is becoming a huge problem. For physical needs, doctors and researchers recommend constant physical exercises to keep the...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Aabroo Saeed via Digital Information World

Range Slider Style 55

The post Range Slider Style 55 appeared first on Best jQuery.


by Admin via Best jQuery

CSS Timeline Style 90

The post CSS Timeline Style 90 appeared first on Best jQuery.


by Admin via Best jQuery

5 Essential Best Practices for SMBs to Reduce CyberSecurity Risk

It doesn't get much media mileage, but more than half of small- and medium-sized businesses have experienced a breach. They typically get up to 5,000 security alerts and are only able to investigate around 55.6 percent of these. SMBs are reporting losses, as well. Around three out of 10...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

Google Is Developing An Improved Dark Mode and Up/Down Vote Buttons For Its News App

In the past few years, the dark mode has become very common in most of the digital platforms, though the implementation has not been flawless. In 2018, Google News started testing a dark mode, but the update had restricted features. For example, Menus and some news articles [If individually...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Abdullah Matloob via Digital Information World