Home > Web Front-end > CSS Tutorial > How to enlarge div in css3

How to enlarge div in css3

WBOY
Release: 2021-12-15 14:35:56
Original
7455 people have browsed it

Method: 1. Use the transform attribute and scale() function to enlarge the div. The syntax is "Element {transform:scale (magnification)}"; 2. Use the width and height attributes to achieve the effect of enlarging the div. The syntax is: "Element {width: width; height: height}".

How to enlarge div in css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to enlarge div in css3

In css, if you want to enlarge a div, you can use the transform attribute and the width and height attributes. accomplish.

1. Use the transform attribute with the scale() function to achieve the effect of enlarging the div

The transform attribute applies 2D or 3D transformation to the element. This property allows us to rotate, scale, move or tilt the element.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin:0 auto;
    }
  .div1{
    width:150px;
    height:100px;
    background:pink;
    transform:scale(1.5);
  }
  .div2{
    width:150px;
    height:100px;
    background:pink;
  }
  </style>
</head>
<body>
<div class="div1"></div>
<br><br>
<div class="div2"></div>
</body>
</html>
Copy after login

Output result:

How to enlarge div in css3

2. Use the width and height attributes to achieve the effect of enlarging the div.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
  .div1{
    width:300px;
    height:200px;
    background:pink;
  }
  .div2{
    width:150px;
    height:100px;
    background:pink;
  }
  </style>
</head>
<body>
<div class="div1"></div>
<br><br>
<div class="div2"></div>
</body>
</html>
Copy after login

Output result:

How to enlarge div in css3

(Learning video sharing: css video tutorial)

The above is the detailed content of How to enlarge div in css3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template