菜单
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP 如何做 W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA 生成式 AI SCIPY AWS 网络安全 数据科学
     ❯   

JS 参考手册

按类别划分的 JS 按字母划分的 JS

JavaScript

JS 数组 JS 布尔值 JS 类 JS 日期 JS 错误 JS 全局 JS JSON JS Map JS Math JS 数字 JS 对象 JS 运算符 JS 优先级 JS Promise JS 正则表达式 JS Set JS 语句 JS 字符串 JS TypedArray

Window

Window 对象 Window Console Window History Window Location Window Navigator Window Screen

HTML DOM

HTML 文档 HTML 元素 HTML 属性 HTML 集合 HTML NodeList HTML DOMTokenList HTML 样式
alignContent alignItems alignSelf animation animationDelay animationDirection animationDuration animationFillMode animationIterationCount animationName animationTimingFunction animationPlayState background backgroundAttachment backgroundClip backgroundColor backgroundImage backgroundOrigin backgroundPosition backgroundRepeat backgroundSize backfaceVisibility border borderBottom borderBottomColor borderBottomLeftRadius borderBottomRightRadius borderBottomStyle borderBottomWidth borderCollapse borderColor borderImage borderImageOutset borderImageRepeat borderImageSlice borderImageSource borderImageWidth borderLeft borderLeftColor borderLeftStyle borderLeftWidth borderRadius borderRight borderRightColor borderRightStyle borderRightWidth borderSpacing borderStyle borderTop borderTopColor borderTopLeftRadius borderTopRightRadius borderTopStyle borderTopWidth borderWidth bottom boxShadow boxSizing captionSide caretColor clear clip color columnCount columnFill columnGap columnRule columnRuleColor columnRuleStyle columnRuleWidth columns columnSpan columnWidth counterIncrement counterReset cssFloat cursor direction display emptyCells filter flex flexBasis flexDirection flexFlow flexGrow flexShrink flexWrap font fontFamily fontSize fontStyle fontVariant fontWeight fontSizeAdjust height isolation justifyContent left letterSpacing lineHeight listStyle listStyleImage listStylePosition listStyleType margin marginBottom marginLeft marginRight marginTop maxHeight maxWidth minHeight minWidth objectFit objectPosition opacity order orphans outline outlineColor outlineOffset outlineStyle outlineWidth overflow overflowX overflowY padding paddingBottom paddingLeft paddingRight paddingTop pageBreakAfter pageBreakBefore pageBreakInside perspective perspectiveOrigin position quotes resize right scrollBehavior tableLayout tabSize textAlign textAlignLast textDecoration textDecorationColor textDecorationLine textDecorationStyle textIndent textOverflow textShadow textTransform top transform transformOrigin transformStyle transition transitionProperty transitionDuration transitionTimingFunction transitionDelay unicodeBidi userSelect verticalAlign visibility width wordBreak wordSpacing wordWrap widows zIndex

HTML 事件

HTML 事件 HTML 事件对象 HTML 事件属性 HTML 事件方法

Web API

API Canvas API Console API Fetch API Fullscreen API 地理位置 API History API MediaQueryList API Storage API 验证 API Web

HTML 对象

<a> <abbr> <address> <area> <article> <aside> <audio> <b> <base> <bdo> <blockquote> <body> <br> <button> <canvas> <caption> <cite> <code> <col> <colgroup> <datalist> <dd> <del> <details> <dfn> <dialog> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <footer> <form> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <ins> <input> button <input> checkbox <input> color <input> date <input> datetime <input> datetime-local <input> email <input> file <input> hidden <input> image <input> month <input> number <input> password <input> radio <input> range <input> reset <input> search <input> submit <input> text <input> time <input> url <input> week <kbd> <label> <legend> <li> <link> <map> <mark> <menu> <menuitem> <meta> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <s> <samp> <script> <section> <select> <small> <source> <span> <strong> <style> <sub> <summary> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <textarea> <time> <title> <track> <u> <ul> <var> <video>

其他参考

CSSStyleDeclaration JS 转换


HTML DOM Style 对象


Style 对象

Style 对象表示单个样式语句。


Style 对象属性

属性 描述
alignContent 设置或返回弹性容器内各行之间的对齐方式,当项目未完全利用所有可用空间时
alignItems 设置或返回弹性容器内项目的对齐方式
alignSelf 设置或返回弹性容器内选定项目的对齐方式
animation 除了 animationPlayState 属性外,所有以下动画属性的简写属性
animationDelay 设置或返回动画何时开始
animationDirection 设置或返回动画是否应在交替周期中反向播放
animationDuration 设置或返回动画完成一个周期需要多少秒或毫秒
animationFillMode 设置或返回动画在执行时间之外应用的属性值
animationIterationCount 设置或返回动画应播放的次数
animationName 设置或返回 @keyframes 动画的名称
animationTimingFunction 设置或返回动画的速度曲线
animationPlayState 设置或返回动画是正在运行还是已暂停
background 在一个声明中设置或返回所有 background 属性
backgroundAttachment 设置或返回背景图像是固定还是随页面滚动
backgroundColor 设置或返回元素的背景颜色
backgroundImage 设置或返回元素的背景图像
backgroundPosition 设置或返回背景图像的起始位置
backgroundRepeat 设置或返回如何重复(平铺)背景图像
backgroundClip 设置或返回背景的绘制区域
backgroundOrigin 设置或返回背景图像的定位区域
backgroundSize 设置或返回背景图像的大小
backfaceVisibility 设置或返回元素在不面向屏幕时是否可见
border 在一个声明中设置或返回 borderWidth, borderStyle 和 borderColor
borderBottom 在一个声明中设置或返回所有 borderBottom 属性
borderBottomColor 设置或返回下边框的颜色
borderBottomLeftRadius 设置或返回左下角的边框形状
borderBottomRightRadius 设置或返回右下角的边框形状
borderBottomStyle 设置或返回下边框的样式
borderBottomWidth 设置或返回下边框的宽度
borderCollapse 设置或返回表格边框是否应合并为单个边框
borderColor 设置或返回元素的边框颜色(最多可以有四个值)
borderImage 用于设置或返回所有 borderImage 属性的简写属性
borderImageOutset 设置或返回边框图像区域超出边框盒的量
borderImageRepeat 设置或返回图像边框是重复、圆形还是拉伸
borderImageSlice 设置或返回图像边框的内边距
borderImageSource 设置或返回用作边框的图像
borderImageWidth 设置或返回图像边框的宽度
borderLeft 在一个声明中设置或返回所有 borderLeft 属性
borderLeftColor 设置或返回左边框的颜色
borderLeftStyle 设置或返回左边框的样式
borderLeftWidth 设置或返回左边框的宽度
borderRadius 用于设置或返回所有四个 borderRadius 属性的简写属性
borderRight 在一个声明中设置或返回所有 borderRight 属性
borderRightColor 设置或返回右边框的颜色
borderRightStyle 设置或返回右边框的样式
borderRightWidth 设置或返回右边框的宽度
borderSpacing 设置或返回表格中单元格之间的间距
borderStyle 设置或返回元素的边框样式(最多可以有四个值)
borderTop 在一个声明中设置或返回所有 borderTop 属性
borderTopColor 设置或返回上边框的颜色
borderTopLeftRadius 设置或返回左上角的边框形状
borderTopRightRadius 设置或返回右上角的边框形状
borderTopStyle 设置或返回上边框的样式
borderTopWidth 设置或返回上边框的宽度
borderWidth 设置或返回元素的边框宽度(最多可以有四个值)
bottom 设置或返回定位元素的底部位置
boxDecorationBreak 设置或返回元素在分页符或内联元素在换行符处的背景和边框行为。
boxShadow 为一个或多个盒子添加阴影
boxSizing 允许您以特定方式定义某些元素以适应区域
captionSide 设置或返回表格标题的位置
caretColor 设置或返回元素的插入符/光标颜色
清除 设置或返回元素相对于浮动对象的位置
clip 设置或返回定位元素可见部分的裁剪区域
color 设置或返回文本颜色
columnCount 设置或返回元素应分为的列数
columnFill 设置或返回如何填充列
columnGap 设置或返回列之间的间隙
columnRule 用于设置或返回所有 columnRule 属性的简写属性
columnRuleColor 设置或返回列之间分隔线的颜色
columnRuleStyle 设置或返回列之间分隔线的样式
columnRuleWidth 设置或返回列之间分隔线的宽度
columns 用于设置或返回 columnWidth 和 columnCount 的简写属性
columnSpan 设置或返回元素应跨越的列数
columnWidth 设置或返回列的宽度
content 与 :before 和 :after 伪元素一起使用,以插入生成的内容
counterIncrement 递增一个或多个计数器
counterReset 创建或重置一个或多个计数器
cursor 设置或返回鼠标指针显示的游标类型
direction 设置或返回文本方向
display 设置或返回元素的显示类型
emptyCells 设置或返回是否显示空单元格的边框和背景
筛选器 设置或返回图像滤镜(视觉效果,如模糊和饱和度)
flex 设置或返回项目的长度,相对于其余项目
flexBasis 设置或返回弹性项目的初始长度
flexDirection 设置或返回弹性项目的方向
flexFlow flexDirection 和 flexWrap 属性的简写属性
flexGrow 设置或返回项目相对于其余项目的增长量
flexShrink 设置或返回项目相对于其余项目的收缩量
flexWrap 设置或返回弹性项目是否应换行
cssFloat 设置或返回元素的水平对齐方式
font 在一个声明中设置或返回 fontStyle, fontVariant, fontWeight, fontSize, lineHeight 和 fontFamily
fontFamily 设置或返回文本的字体系列
fontSize 设置或返回文本的字体大小
fontStyle 设置或返回字体的样式是正常、斜体还是倾斜
fontVariant 设置或返回字体是否应显示为小型大写字母
fontWeight 设置或返回字体的粗细
fontSizeAdjust 在字体回退发生时保留文本的可读性
fontStretch 从字体系列中选择正常、压缩或扩展的字形
hangingPunctuation 指定标点符号是否可以放置在线框之外
height 设置或返回元素的高度
hyphens 设置如何拆分单词以改善段落布局
icon 为作者提供了使用图标等效样式化元素的能力
imageOrientation 指定用户代理应用于图像的向右或顺时针旋转
isolation 定义元素是否必须创建新的堆叠上下文
justifyContent 设置或返回弹性容器内项目之间的对齐方式,当项目未完全利用所有可用空间时。
left 设置或返回定位元素的左侧位置
letterSpacing 设置或返回文本中字符之间的间距
lineHeight 设置或返回文本中行之间的距离
listStyle 在一个声明中设置或返回 listStyleImage, listStylePosition 和 listStyleType
listStyleImage 设置或返回图像作为列表项标记
listStylePosition 设置或返回列表项标记的位置
listStyleType 设置或返回列表项标记类型
margin 设置或返回元素的边距(最多可以有四个值)
marginBottom 设置或返回元素的下边距
marginLeft 设置或返回元素的左边距
marginRight 设置或返回元素的右边距
marginTop 设置或返回元素的上边距
maxHeight 设置或返回元素的最大高度
maxWidth 设置或返回元素的最大宽度
minHeight 设置或返回元素的最小高度
minWidth 设置或返回元素的最小宽度
navDown 设置或返回使用向下箭头导航键时导航到的位置
navIndex 设置或返回元素的 Tab 键顺序
navLeft 设置或返回使用向左箭头导航键时导航到的位置
navRight 设置或返回使用向右箭头导航键时导航到的位置
navUp 设置或返回使用向上箭头导航键时导航到的位置
objectFit 指定替换元素的内容如何适应其已用高度和宽度所建立的框
objectPosition 指定替换元素在其框内的对齐方式
不透明度 设置或返回元素的透明度级别
order 设置或返回弹性项目的顺序,相对于其余项目
orphans 设置或返回当元素内发生分页符时,必须留在页面底部的元素的最小行数
outline 在一个声明中设置或返回所有 outline 属性
outlineColor 设置或返回元素周围轮廓的颜色
outlineOffset 偏移轮廓,并将其绘制在边框边缘之外
outlineStyle 设置或返回元素周围轮廓的样式
outlineWidth 设置或返回元素周围轮廓的宽度
overflow 设置或返回如何处理超出元素框的内容
overflowX 指定如果内容溢出元素的区域,如何处理内容的左/右边缘
overflowY 指定如果内容溢出元素的区域,如何处理内容的上/下边缘
padding 设置或返回元素的内边距(最多可以有四个值)
paddingBottom 设置或返回元素的下内边距
paddingLeft 设置或返回元素的左内边距
paddingRight 设置或返回元素的右内边距
paddingTop 设置或返回元素的上内边距
pageBreakAfter 设置或返回元素后的分页符行为
pageBreakBefore 设置或返回元素前的分页符行为
pageBreakInside 设置或返回元素内的分页符行为
perspective 设置或返回如何查看 3D 元素的透视
perspectiveOrigin 设置或返回 3D 元素的底部位置
position 设置或返回元素使用的定位方法类型(static、relative、absolute 或 fixed)
quotes 设置或返回嵌入式引用的引号类型
resize 设置或返回元素是否可由用户调整大小
right 设置或返回定位元素的右侧位置
scrollBehavior 指定当用户单击可滚动框中的链接时,是平滑动画滚动位置,还是直接跳转
tableLayout 设置或返回表格单元格、行和列的布局方式
tabSize 设置或返回 Tab 字符的长度
textAlign 设置或返回文本的水平对齐方式
textAlignLast 设置或返回当 text-align 为 "justify" 时,块的最后一行或强制换行符之前的行的对齐方式
textDecoration 设置或返回文本的装饰
textDecorationColor 设置或返回文本装饰的颜色
textDecorationLine 设置或返回文本装饰中线的类型
textDecorationStyle 设置或返回文本装饰中线的样式
textIndent 设置或返回文本第一行的缩进
textJustify 设置或返回当 text-align 为 "justify" 时使用的对齐方法
textOverflow 设置或返回当文本溢出包含元素时应发生的情况
textShadow 设置或返回文本的阴影效果
textTransform 设置或返回文本的大小写
top 设置或返回定位元素的顶部位置
转换 对元素应用 2D 或 3D 变换
transformOrigin 设置或返回变换元素的位置
transformStyle 设置或返回嵌套元素在 3D 空间中的渲染方式
transition 用于设置或返回所有四个 transition 属性的简写属性
transitionProperty 设置或返回过渡效果所针对的 CSS 属性
transitionDuration 设置或返回过渡效果完成所需的时间(秒或毫秒)
transitionTimingFunction 设置或返回过渡效果的速度曲线
transitionDelay 设置或返回过渡效果何时开始
unicodeBidi 设置或返回是否应覆盖文本以支持同一文档中的多种语言
userSelect 设置或返回元素中的文本是否可以被选中
verticalAlign 设置或返回元素中内容的垂直对齐方式
可见性 设置或返回元素是否可见
whiteSpace 设置或返回如何处理文本中的 Tab 键、换行符和空格
width 设置或返回元素的宽度
wordBreak 为非 CJK 脚本设置或返回断行规则
wordSpacing 设置或返回文本中单词之间的间距
wordWrap 允许长的、不可断开的单词断开并换到下一行
widows 设置或返回元素在页面顶部必须可见的最小行数
zIndex 设置或返回定位元素的堆叠顺序


访问 Style 对象

Style 对象可以从文档的头部部分或特定的 HTML 元素中访问。

从文档头部部分访问 Style 对象

示例

var x = document.getElementsByTagName("STYLE");
自己动手试一试 »

访问指定元素的 Style 对象

示例

var x = document.getElementById("myH1").style;
自己动手试一试 »

创建 Style 对象

您可以使用 document.createElement() 方法创建一个 <style> 元素

示例

var x = document.createElement("STYLE");
自己动手试一试 »

您还可以设置现有元素的样式属性

示例

document.getElementById("myH1").style.color = "red";
自己动手试一试 »

相关页面

HTML 教程: HTML CSS

CSS 教程: CSS 教程

HTML 参考: HTML <style> 标签

CSS 参考: CSS 属性


×

联系销售

如果您想将 W3Schools 服务用于教育机构、团队或企业,请发送电子邮件给我们
sales@w3schools.com

报告错误

如果您想报告错误,或想提出建议,请发送电子邮件给我们
help@w3schools.com

W3Schools 经过优化,旨在方便学习和培训。示例可能经过简化,以提高阅读和学习体验。教程、参考资料和示例会不断审查,以避免错误,但我们无法保证所有内容的完全正确性。使用 W3Schools 即表示您已阅读并接受我们的使用条款Cookie 和隐私政策

版权所有 1999-2024 Refsnes Data。保留所有权利。W3Schools 由 W3.CSS 提供支持