Q-CSS:CSS 属性 → QML 属性对照表

类型CSS 属性QML 属性说明 / 适用类型
盒模型与视觉width / heightwidth / height所有可视元素
盒模型与视觉min-width / min-heightminWidth / minHeightItem
盒模型与视觉max-width / max-heightmaxWidth / maxHeightItem
盒模型与视觉background-colorcolorRectangle
盒模型与视觉background-imagesourceImage / BorderImage
盒模型与视觉border: 1px solid #cccborder.width: 1; border.color: "#ccc"Rectangle
盒模型与视觉border-radiusradiusRectangle
盒模型与视觉box-shadowDropShadow 效果layer.effect
盒模型与视觉opacityopacity所有 Item
盒模型与视觉display: nonevisible: false所有 Item
盒模型与视觉overflow: hiddenclip: trueItem
盒模型与视觉overflow: auto / scrollFlickable / ScrollView容器
盒模型与视觉cursor: pointercursorShape: Qt.PointingHandCursor鼠标交互区域
盒模型与视觉z-indexzItem
盒模型与视觉transform: translate(x, y)x / y 或 transform: Translate { x: N; y: N }Item
盒模型与视觉transform: rotate(45deg)rotation: 45Item
盒模型与视觉transform: scale(1.5)scale: 1.5Item
盒模型与视觉transform-origintransformOrigin: Item.TopLeftItem
字体与文本font-size: 16pxfont.pixelSize: 16Text
字体与文本font-weight: boldfont.bold: trueText
字体与文本font-weight: 600font.weight: Font.DemiBoldText
字体与文本font-family: "Arial"font.family: "Arial"Text
字体与文本font-style: italicfont.italic: trueText
字体与文本text-align: centerhorizontalAlignment: Text.AlignHCenterText
字体与文本vertical-align: middleverticalAlignment: Text.AlignVCenterText
字体与文本color: red(文字颜色)color: "red"Text
字体与文本line-height: 1.5lineHeight: 1.5Text
字体与文本text-decoration: underlinefont.underline: trueText
字体与文本text-overflow: ellipsiselide: Text.ElideRightText
字体与文本white-space: nowrapwrapMode: Text.NoWrapText
字体与文本word-break: break-allwrapMode: Text.WordWrapText
字体与文本text-shadowlayer.effect: DropShadowText + layer
布局与间距margin: 10pxanchors.margins: 10锚点边距
布局与间距margin-top: 10pxanchors.topMargin: 10上边距
布局与间距padding: 10pxanchors.margins: 10(容器内子元素)内边距
布局与间距gap: 10pxspacing: 10Row / Column / Grid
布局与间距display: flexRow / Column弹性布局
布局与间距flex-direction: rowRow { }水平排列
布局与间距flex-direction: columnColumn { }垂直排列
布局与间距flex-wrap: wrapFlow { }自动换行
布局与间距justify-content: centeranchors.horizontalCenter: parent.horizontalCenter水平居中
布局与间距align-items: centeranchors.verticalCenter: parent.verticalCenter垂直居中
布局与间距flex: 1Layout.fillWidth: true; Layout.fillHeight: true填充剩余空间
布局与间距display: gridGrid { columns: 3 } 或 GridLayout网格布局
布局与间距position: absolutex: N; y: N绝对定位
布局与间距position: relative默认(QML 元素默认相对定位)相对定位
布局与间距position: fixed无直接对应,通过 anchors + 窗口坐标模拟固定定位
过渡与动画transition: all 0.3s easeBehavior { NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } }属性过渡
过渡与动画@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }OpacityAnimator { from: 0; to: 1; duration: 300 }关键帧动画
过渡与动画animation: spin 2s linear infiniteRotationAnimation { duration: 2000; loops: Animation.Infinite }循环动画
过渡与动画transform: translateX(100px)Translate { x: 100 } + NumberAnimation位移动画
过渡与动画transition-delayPauseAnimation { duration: 200 }动画延迟