Open In App
Related Articles

How to Rotate Container Background Image using CSS ?

Improve Article
Save Article
Like Article

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">


Last Updated : 13 May, 2020
Like Article
Save Article
Similar Reads
Related Tutorials