CSS3 基础(011_用户接口)

原始网址:http://www.w3schools.com/css/css3_user_interface.asp

翻译:

CSS3 用户接口(CSS3 User Interface)


CSS3 用户接口

CSS3 有新的用户接口特点,例如 resizing elementsoutlines 以及 box sizing
本章,你将学习以下用户接口属性:

  • resize
  • outline-offset

Browser Support

表格里的数字代表对 CSS3 属性全面支持的各浏览器的第一个版本号。
数字之后跟从 -webkit--moz- 指定带前缀工作的第一个版本号。

属性(Property)chromeIEfirefoxsafariopera
word-break4.0Not supported5.0
4.0 -moz-
4.015.0
word-break4.0Not supported5.0
4.0 -moz-
4.09.5

CSS3 Resizing

resize 属性指定用户对元素是否可调整大小。
下列示例允许用户只可调整 <div> 元素的宽度:

div {
    resize: horizontal;
    overflow: auto;
}
<!DOCTYPE html>
<html>
<head>
<style>
div {
    border: 2px solid;
    padding: 20px;
    width: 300px;
    resize: horizontal;
    overflow: auto;
}
</style>
</head>
<body>
    <p><b>Note:</b> Internet Explorer does not support the resize property.</p>
    <div>Let the user resize the width of this div element.</div>
</body>
</html>

下列示例允许用户只可调整 <div> 元素的高度:

div {
    resize: vertical;
    overflow: auto;
}
<!DOCTYPE html>
<html>
<head>
<style>
div {
    border: 2px solid;
    padding: 20px;
    width: 300px;
    resize: vertical;
    overflow: auto;
}
</style>
</head>
<body>
    <p><b>Note:</b> Internet Explorer does not support the resize property.</p>
    <div>Let the user resize the height of this div element.</div>
</body>
</html>

下列示例允许用户可调整 <div> 元素的宽和高:

div {
    resize: both;
    overflow: auto;
}
<!DOCTYPE html>
<html>
<head>
<style>
div {
    border: 2px solid;
    padding: 20px;
    width: 300px;
    resize: both;
    overflow: auto;
}
</style>
</head>
<body>
    <p><b>Note:</b> Internet Explorer does not support the resize property.</p>
    <div>Let the user resize both the height and the width of this div element.</div>
</body>
</html>

CSS3 Outline Offset

outline-offset 属性在元素的轮廓和边界或边框之间增加空白。
轮廓和边框有以下区别:

  • 轮廓是围绕元素的线,位于边框之外
  • 轮廓不占空间
  • 轮廓可以是非矩形

下列示例使用 outline-offset 属性在边框和轮廓之间增加 15px 的空间:

div {
    border: 1px solid black;
    outline: 1px solid red;
    outline-offset: 15px;
}
<!DOCTYPE html>
<html>
<head>
<style>
div {
    margin: 20px;
    padding: 10px;
    width: 300px;
    height: 100px;
    border: 1px solid black;
    outline: 1px solid red; /* Move the outline 15px away from the border */
    outline-offset: 15px;
}
</style>
</head>
<body>
    <p><b>Note:</b> Internet Explorer does not support the outline-offset property.</p>
    <div>This div has an outline 15px outside the border edge.</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值