IE6中用了float:left之后导致margin-left加倍

本文探讨了在Internet Explorer 6浏览器中,当元素设置了浮动(float)和左外边距(margin-left)时出现的显示异常问题。文中提供了一个简单的解决方案:通过将display属性设置为inline来修正IE6解释上的偏差。
先看css代码:
<style lang="scss" scoped> .el-date-editor.el-input { width: auto; } .add-update-preview .el-form-item /deep/ .el-form-item__label { padding: 0 10px 0 0; color: #999; font-weight: 600; width: 180px; font-size: 16px; line-height: 40px; text-align: right; } .add-update-preview .el-form-item /deep/ .el-form-item__content { margin-left: 180px; } .add-update-preview .el-input /deep/ .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; height: 40px; } .add-update-preview .el-select /deep/ .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; min-width: 50%; height: 40px; } .add-update-preview .el-date-editor /deep/ .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 10px 0 30px; color: #000; background: #fff; width: 100%; font-size: 16px; height: 40px; } .add-update-preview /deep/ .el-upload--picture-card { background: transparent; border: 0; border-radius: 0; width: auto; height: auto; line-height: initial; vertical-align: middle; } .add-update-preview /deep/ .el-upload-list .el-upload-list__item { border: 1px solid #e8e8e8; cursor: pointer; border-radius: 0px; color: #666; background: #fff; width: 150px; font-size: 34px; line-height: 150px; text-align: center; height: 150px; } .add-update-preview /deep/ .el-upload .el-icon-plus { border: 1px solid #e8e8e8; cursor: pointer; border-radius: 0px; color: #666; background: #fff; width: 150px; font-size: 34px; line-height: 150px; text-align: center; height: 150px; } .add-update-preview .el-textarea /deep/ .el-textarea__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 12px; color: #666; background: #fff; width: 100%; font-size: 14px; min-width: 400px; height: 120px; } .add-update-preview .btn3 { border: 0px solid #ccc; cursor: pointer; border-radius: 4px; padding: 0 10px; margin: 0 10px 0 0; color: #fff; background: #50adfd; width: auto; font-size: 16px; min-width: 110px; height: 40px; } .add-update-preview .btn3:hover { opacity: 0.8; } </style>
09-12
你当前的 `<style>` 块使用了 `lang="scss"` 并且包含 `/deep/`,这是 Vue 2 中用于穿透 `scoped` 样式的一种方式。然而,在 SCSS/Sass 中,`/` 是数学运算符,不是合法的选择器语法,因此会报错。 --- ## ✅ 正确写法(使用 `::v-deep` 替代 `/deep/`) 在 SCSS 中,推荐使用 `::v-deep` 来穿透 `scoped` 样式: ### ✅ 修改后的完整代码如下: ```vue <style lang="scss" scoped> .el-date-editor.el-input { width: auto; } .add-update-preview { ::v-deep .el-form-item .el-form-item__label { padding: 0 10px 0 0; color: #999; font-weight: 600; width: 180px; font-size: 16px; line-height: 40px; text-align: right; } ::v-deep .el-form-item .el-form-item__content { margin-left: 180px; } ::v-deep .el-input .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; height: 40px; } ::v-deep .el-select .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; min-width: 50%; height: 40px; } ::v-deep .el-date-editor .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 10px 0 30px; color: #000; background: #fff; width: 100%; font-size: 16px; height: 40px; } ::v-deep .el-upload--picture-card { background: transparent; border: 0; border-radius: 0; width: auto; height: auto; line-height: initial; vertical-align: middle; } ::v-deep .el-upload-list .el-upload-list__item { border: 1px solid #e8e8e8; cursor: pointer; border-radius: 0px; color: #666; background: #fff; width: 150px; font-size: 34px; line-height: 150px; text-align: center; height: 150px; } ::v-deep .el-upload .el-icon-plus { border: 1px solid #e8e8e8; cursor: pointer; border-radius: 0px; color: #666; background: #fff; width: 150px; font-size: 34px; line-height: 150px; text-align: center; height: 150px; } ::v-deep .el-textarea .el-textarea__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 12px; color: #666; background: #fff; width: 100%; font-size: 14px; min-width: 400px; height: 120px; } } .add-update-preview .btn3 { border: 0px solid #ccc; cursor: pointer; border-radius: 4px; padding: 0 10px; margin: 0 10px 0 0; color: #fff; background: #50adfd; width: auto; font-size: 16px; min-width: 110px; height: 40px; } .add-update-preview .btn3:hover { opacity: 0.8; } </style> ``` --- ## ✅ 优化建议 你可以利用 SCSS 的嵌套特性来进一步优化结构,使代码更简洁: ```scss .add-update-preview { ::v-deep { .el-form-item { & .el-form-item__label { padding: 0 10px 0 0; color: #999; font-weight: 600; width: 180px; font-size: 16px; line-height: 40px; text-align: right; } & .el-form-item__content { margin-left: 180px; } } .el-input .el-input__inner, .el-select .el-input__inner, .el-date-editor .el-input__inner { border: 1px solid #e8e8e8; border-radius: 0px; padding: 0 12px; color: #000; width: 100%; font-size: 16px; height: 40px; } .el-date-editor .el-input__inner { padding: 0 10px 0 30px; } } } ``` --- ## ✅ 如果你使用的是 Vue 3 在 Vue 3 中,可以使用 `:deep()` 语法替代 `::v-deep`: ```scss :deep(.el-form-item .el-form-item__label) { background-color: #f5f7fa !important; } ``` --- ##
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值