How To Use CSS Transform Property For HTML Elements

admin_img Posted By Bajarangi soft , Posted On 05-11-2020

In CSS The translate() method moves an element from its current position (according to the parameters given for the X-axis and the Y-axis).So today we discuss how to do it.

How To Use CSS Transform Property For HTML Elements

CSS To Change The Position Of HTML Element.

.div1{
    width: 300px;
    height: 100px;
    background-color: lightpink;
    border: 1px solid black;
    -ms-transform: translate(50px,100px); /* IE 9 */
    transform: translate(50px,20px); /* Standard syntax */
}

Complete Code For Using CSS Transform Property For HTML Elements.

<!DOCTYPE html>
<html>
<head>
    <title>How To Use CSS Transform Property For HTML Elements</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>

</head>
<style>
    body {
        background: #c7254e;
    }
    .div1{
        width: 300px;
        height: 100px;
        background-color: lightpink;
        border: 1px solid black;
        -ms-transform: translate(50px,100px); /* IE 9 */
        transform: translate(50px,20px); /* Standard syntax */
    }
</style>
<body>
<br/><br/>
<div class="container">
    <br>
    <div class="text-center">
        <h1 id="color" style="color: white;"> CSS Transform Property For HTML Elements</h1>
    </div>
    <br>
    <div class="well">
        <h1>The translate() Method</h1>
        <p>The translate() method moves an element from its current position:</p>

        <div class="div1">
            This div element is moved 50 pixels to the right, and 100 pixels down from its current position.
        </div>

    </div>
</div>
</body>
</html>

Related Post