resize不是已知的css属性?


本文摘自PHP中文网,作者青灯夜游,侵删。

resize是已知的css属性。resize是CSS3中新增的一个属性,用于指定一个元素是否是由用户调整大小的;resize属性允许用户通过拖动的方式,来自由缩放元素的尺寸。

  • 该方法适用于所有品牌的电脑。

相关推荐:《CSS3视频教程》

css resize属性

resize属性可以指定一个元素是否是由用户调整大小的。

resize是CSS3中新增的一个属性,它允许用户通过拖动的方式,来自由缩放元素的尺寸,用以增强用户体验。这在以前只能通过Javascript 编写大量脚本来实现,费时费力,效率低下。

resize属性可以用于根据用户需要以及在哪个方向上调整元素的大小。 resize属性可以采用4个值。

句法:

1

2

3

Element{

    Resize : none|both|vertical|horizontal;

}

让我们看一下每个属性...

1) resize : none

当用户不想调整元素的大小时, none值不会应用于resize属性 。 也是默认值。

句法:

1

2

3

Element{

    resize:none;

}

例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<!DOCTYPE html>

 

<html>

 

<head>

    <style>

        p {

            border: 3px solid;

            padding: 15px;

            width: 300px;

            resize: none;

        }

    </style>

</head>

 

<body>

    <h1>The resize Property</h1>

    <p>

        <p>None value doesn’t allow resizing of this p element.</p>

    </p>

</body>

 

</html>

输出

CSS | resize Property | Example 1

在上面的示例中,您无法调整p元素的大小。 它是静态的。

2) resize : both

当用户希望其元素在宽度和高度的两侧都可调整大小时, 两个值都将应用于resize属性

句法:

1

2

3

Element{

    resize:both;

}

例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<!DOCTYPE html>

 

<html>

 

<head>

    <style>

        p {

            border: 3px solid;

            padding: 15px;

            width: 300px;

            resize: both;

            overflow: auto;

        }

    </style>

</head>

 

<body>

    <h1>The resize Property</h1>

    <p>

        <p>click and drag the bottom right corner to resize the height and width of this p element.</p>

    </p>

</body>

 

</html>

输出

CSS | resize Property | Example 2

在上面的示例中,要调整大小,请单击并拖动此p元素的右下角。

3) resize : vertical

当用户要根据需要调整元素的高度时,将垂直值应用于resize属性

句法:

1

2

3

Element{

    resize:vertical;

}

例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<!DOCTYPE html>

 

<html>

 

<head>

    <style>

        p {

            border: 3px solid;

            padding: 15px;

            width: 300px;

            resize: vertical;

            overflow: auto;

        }

    </style>

</head>

 

<body>

    <h1>The resize Property</h1>

    <p>

        <p>click and drag the bottom right corner to resize the height of this p element.</p>

    </p>

</body>

 

</html>

输出

CSS | resize Property | Example 3

在上面的示例中,用户可以单击并拖动此p元素的右下角以调整其高度。

4) resize : horizontal

当用户要根据需要调整元素的宽度大小时,将水平值应用于resize属性

句法:

1

2

3

Element{

    resize:horizontal;

}

例:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<!DOCTYPE html>

 

<html>

 

<head>

    <style>

        p {

            border: 3px solid;

            padding: 15px;

            width: 300px;

            resize: horizontal;

            overflow: auto;

        }

    </style>

</head>

 

<body>

    <h1>The resize Property</h1>

    <p>

        <p>click and drag the bottom right corner to resize the width of this p element.</p>

    </p>

</body>

 

</html>

输出

CSS | resize Property | Example 4

在上面的示例中,用户可以单击并拖动此p元素的右下角以调整其宽度。

更多编程相关知识,请访问:编程教学!!

以上就是resize不是已知的css属性?的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

声明你的第一个css变量

css3和less的区别是什么

css有几种引入方式

css letter-spacing属性怎么用

css+html实现模拟百度首页(附代码)

css怎么使用display显示隐藏元素

:empty是什么?怎么使用?

css如何实现表格实线

css3二级导航菜单制作步骤详解

css sprites如何使用?

更多相关阅读请进入《resize》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...