How to Rotate Container Background Image using CSS ?

The CSS background-image property is used to add an image to the background of an element. In this article, the task is to rotate the image which is used in the background.

Approach: The CSS transform property is used to apply two-dimensional or three-dimensional transformation to a element. This property can be used to rotate, scale, move or even skew an element.


.class_name { transform: value } 

Example: We can use the CSS transform property to fix this issue and make rotations as given below:





<!DOCTYPE html>
    <!-- Bootstrap CDN -->
    <link rel="stylesheet"
    <!-- CSS -->
        .background-image {
            background-image: url('Geeksforgeeks_image.jpg');
            background-repeat: no-repeat;
            height: 300px;
        .rotated-background-image {
            background-image: url('Geeksforgeeks_image.jpg');
            background-repeat: no-repeat;
            height: 100%;
            margin-top: 250px;
            transform: rotate(90deg);
            /* All browsers support */
            -moz-transform: rotate(90deg);
            -webkit-transform: rotate(90deg);
            -o-transform: rotate(90deg);
            -ms-transform: rotate(90deg);
        .custom {
            height: 100px;
            padding-top: 10px;
    <!-- Normal image which is not rotated -->
    <div class="container custom">
        <div class="background-image">
    <!-- Rotated image -->
    <div class="container">
        <div class="rotated-background-image">



My Personal Notes arrow_drop_up

I love Open Source Culture have contributed to phpMyAdmin, LibreOffice, Ant-Design and Web is my passion

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.