- CSS 教程
- CSS - 首页
- CSS - 路线图
- CSS - 简介
- CSS - 语法
- CSS - 选择器
- CSS - 包含
- CSS - 测量单位
- CSS - 颜色
- CSS - 背景
- CSS - 字体
- CSS - 文本
- CSS - 图片
- CSS - 链接
- CSS - 表格
- CSS - 边框
- CSS - 块级边框
- CSS - 内联边框
- CSS - 外边距
- CSS - 列表
- CSS - 内边距
- CSS - 光标
- CSS - 轮廓
- CSS - 尺寸
- CSS - 滚动条
- CSS - 内联块
- CSS - 下拉菜单
- CSS - 可见性
- CSS - 溢出
- CSS - 清除浮动
- CSS - 浮动
- CSS - 箭头
- CSS - 调整大小
- CSS - 引号
- CSS - 顺序
- CSS - 位置
- CSS - 连字符
- CSS - 悬停
- CSS - 显示
- CSS - 聚焦
- CSS - 缩放
- CSS - 转换
- CSS - 高度
- CSS - 连字符字符
- CSS - 宽度
- CSS - 不透明度
- CSS - Z-Index
- CSS - 底部
- CSS - 导航栏
- CSS - 覆盖层
- CSS - 表单
- CSS - 对齐
- CSS - 图标
- CSS - 图片库
- CSS - 注释
- CSS - 加载器
- CSS - 属性选择器
- CSS - 组合器
- CSS - 根
- CSS - 盒模型
- CSS - 计数器
- CSS - 剪辑
- CSS - 书写模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - 全部
- CSS - 内嵌
- CSS - 隔离
- CSS - 滚动溢出
- CSS - Justify Items
- CSS - Justify Self
- CSS - 制表符大小
- CSS - 指针事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大块级大小
- CSS - 最小块级大小
- CSS - 混合模式
- CSS - 最大内联大小
- CSS - 最小内联大小
- CSS - 偏移量
- CSS - 口音颜色
- CSS - 用户选择
- CSS 高级
- CSS - 网格
- CSS - 网格布局
- CSS - Flexbox
- CSS - 可见性
- CSS - 定位
- CSS - 图层
- CSS - 伪类
- CSS - 伪元素
- CSS - @规则
- CSS - 文本效果
- CSS - 分页媒体
- CSS - 打印
- CSS - 布局
- CSS - 验证
- CSS - 图片精灵
- CSS - 重要
- CSS - 数据类型
- CSS3 教程
- CSS3 - 教程
- CSS - 圆角
- CSS - 边框图片
- CSS - 多重背景
- CSS - 颜色
- CSS - 渐变
- CSS - 盒阴影
- CSS - 盒装饰中断
- CSS - 光标颜色
- CSS - 文本阴影
- CSS - 文本
- CSS - 2d 变换
- CSS - 3d 变换
- CSS - 过渡
- CSS - 动画
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按钮
- CSS - 分页
- CSS - 变量
- CSS - 媒体查询
- CSS - 函数
- CSS - 数学函数
- CSS - 遮罩
- CSS - 形状
- CSS - 样式图片
- CSS - 特异性
- CSS - 自定义属性
- CSS 响应式
- CSS RWD - 简介
- CSS RWD - 视口
- CSS RWD - 网格视图
- CSS RWD - 媒体查询
- CSS RWD - 图片
- CSS RWD - 视频
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 转换器
- CSS - 颜色选择器和动画
- CSS 资源
- CSS - 有用资源
- CSS - 讨论
CSS - max-inline-size 属性
CSS max-inline-size 属性设置元素的最大内联大小。内联的方向由 writing-mode 属性决定。如果内容在元素的内联大小内可以很好地适应,则该属性无效。
语法
max-inline-size: auto | length | percentage | initial | inherit;
属性值
| 值 | 描述 |
|---|---|
| auto | 此值不设置宽度限制。默认值。 |
| 长度 | 它使用长度单位(例如 px、em、rem 等)设置元素的 max-inline-size。 |
| 百分比 | 它使用相对于包含元素大小的百分比值设置元素的 max-inline-size。 |
| initial | 它将属性设置为其默认值。 |
| inherit | 它从父元素继承属性。 |
CSS 最大内联大小属性示例
以下示例使用不同的值说明了 max-inline-size 属性。
使用 Auto 值的最大内联大小属性
为了不设置元素 inline-size 的任何特定限制,我们使用 auto 值。元素的大小取决于内容的长度。以下示例显示了这一点。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.container {
background-color: lightgreen;
max-inline-size: auto;
display: inline-block;
}
</style>
</head>
<body>
<h2>
CSS max-inline-size property
</h2>
<h4>
max-inline-size: auto
</h4>
<div class="container">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
</body>
</html>
使用长度值的最大内联大小属性
要设置元素的内联大小,我们可以使用长度单位(例如 px、em、rem 等)指定大小。指定的大小将应用于元素。如果内容大于元素的大小,它将溢出。以下示例显示了这一点。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.container {
background-color: lightgreen;
margin: 10px;
display: inline-block;
}
.size1 {
max-inline-size: 160px;
}
.size2 {
max-inline-size: 6.5em;
}
</style>
</head>
<body>
<h2>
CSS max-inline-size property
</h2>
<h4>
max-inline-size: 160px
</h4>
<div class="container size1">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
<br/>
<h4>
max-inline-size: 6.5em
</h4>
<div class="container size2">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
</body>
</html>
使用百分比值的最大内联大小属性
要设置元素的内联大小,我们可以使用相对于包含元素大小的百分比值(例如 10%)指定大小。指定的大小将应用于元素。如果内容大于元素的大小,它将溢出。以下示例显示了这一点。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.outer-container {
height: 150px;
}
.container {
display: inline-block;
background-color: lightgreen;
}
.size1 {
max-inline-size: 45%;
}
.size2 {
max-inline-size: 55%;
}
</style>
</head>
<body>
<h2>
CSS max-inline-size property
</h2>
<h4>
max-inline-size: 45% (of the size
of the containing element)
</h4>
<div class="outer-container">
<div class="container size1">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
</div>
<br/>
<h4>
max-inline-size: 55% (of the size
of the containing element)
</h4>
<div class="outer-container">
<div class="container size2">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
</div>
</body>
</html>
使用书写模式的最大内联大小属性
max-inline-size 属性可以与 writing-mode 属性结合使用,该属性确定内联方向。在水平模式下,inline-size 从左到右增长。在垂直模式下,inline-size 从上到下(或从下到上)增长。以下示例显示了这一点。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.outer-container {
height: 150px;
}
.container {
display: inline-block;
background-color: lightgreen;
max-inline-size: 65%;
}
.horizontal {
writing-mode: horizontal-lr;
}
.vertical {
writing-mode: vertical-rl;
}
</style>
</head>
<body>
<h2>
CSS max-inline-size property
</h2>
<h4>
max-inline-size: 65% (of the size of the
containing element); writing-mode: horizontal-lr;
</h4>
<div class="outer-container">
<div class="container horizontal">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
</div>
<br/>
<h4>
max-inline-size: 65% (of the size of the
containing element); writing-mode: vertical-rl;
</h4>
<div class="outer-container">
<div class="container vertical">
<p>
TutorialsPoint offers comprehensive online
tutorials across various subjects, including
programming, web development, and data science.
It provides accessible, step-by-step guides,
practical examples, and interactive learning
resources for learners of all levels.
</p>
</div>
</div>
</body>
</html>
支持的浏览器
| 属性 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| max-inline-size | 57.0 | 79.0 | 41.0 | 12.1 | 44.0 |
css_properties_reference.htm
广告




