CSS: IE中的BUG之margin-bottom失效

本文介绍了一种解决HTML登录页面中输入框样式问题的方法,特别是针对margin-bottom属性在特定情况下的失效问题,并提供了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<div class="inp" id="userdiv"> 
   <label for="UserID" class="inp_lab" id="LabelUserID" onfocus="nameFocus();"> 帐 号 </label> 
   <input name="loginusername" type="text" id="txtUsername" onfocus="nameFocus();" /> 
  </div> 
  <div class="inp"> 
   <label for="UserPassword" class="inp_lab" id="LabelUserPassword"> 密码 </label> 
   <input name="loginpassword" type="password" id="txtPassword" /> 
  </div>

css

.inp { margin:0 25px 13px;height:38px;  position:relative; background:url(../image/loginbg.jpg) repeat-x;}
.inp label { color:#999; font-size:12px; line-height:38px;  padding:0 5px; cursor:text;}
.inp input  { border:1px solid #b9cbdd;width:300px; height:38px; line-height:38px; background:none; padding:0; position:absolute; left:0px; top:0px; font-size:14px; color:#333;}
.inp a { position:absolute; right:0px; top:0px; height:38px; line-height:38px; width:95px; display:inline-block; background:#fff; border-left:1px solid #d5dbe2; color:#999; text-indent:12px; font-size:14px;}
.inp input#txtPassword { font-family:Arial; font-size:20px; line-height:34px;}

inp的margin-bottom 25px;有时会失效

 

解决:.inp margin改为padding

   .inp input  left:0px;改为left:25px;

转载于:https://www.cnblogs.com/miharu/p/4500568.html

<template> <div class="label-container"> <div class="header"> <div style="font-size: 16px;font-weight: 600;color: #333333;">客户特征标签</div> <el-button type="text" @click="togglePopover">更多</el-button> </div> <el-popover v-model="dialogVisible" :append-to-body="true" popper-class="custom-popover" placement="right" width="200" trigger="manual" > <!-- :visible-arrow="false" --> <div class="full-label-section"> <span>业务需求标签</span> <div class="full-tag-group"> <el-tag v-for="(item, index) in requireList" :key="index" type="primary" size="mini" >{{ item.labelName }}</el-tag > </div> </div> <div class="full-label-section"> <span>业务特征标签</span> <div class="full-tag-group"> <el-tag v-for="(item, index) in featureList" :key="index" type="success" size="mini" >{{ item.labelName }}</el-tag > </div> </div> <div class="full-label-section"> <span>拓展任务标签</span> <div class="full-tag-group"> <el-tag v-for="(item, index) in taskList" :key="index" type="danger" size="mini" >{{ item.labelName }}</el-tag > </div> </div> </el-popover> <div class="label-section"> <span>业务需求</span> <div class="tag-group"> <el-tag v-for="(item, index) in showRequireList" :key="index" type="primary" size="mini" >{{ item.labelName }}</el-tag > </div> </div> <div class="label-section"> <span>业务特征</span> <div class="tag-group"> <el-tag v-for="(item, index) in showFeatureList" :key="index" type="success" size="mini" >{{ item.labelName }}</el-tag > </div> </div> <div class="label-section"> <span>拓展任务</span> <div class="tag-group"> <el-tag v-for="(item, index) in showTaskList" :key="index" type="danger" size="mini" >{{ item.labelName }}</el-tag > </div> </div> </div> </template> <script> import { Tag, Button, Popover } from 'element-ui'; export default { name: 'groupLabelBox', components: { [Tag.name]: Tag, [Button.name]: Button, [Popover.name]: Popover, }, props: { requireList: { type: Array, required: true, }, featureList: { type: Array, required: true, }, taskList: { type: Array, required: true, }, }, data() { return { dialogVisible: false, }; }, computed: { showRequireList() { return this.requireList.slice(0, 2); }, showFeatureList() { return this.featureList.slice(0, 2); }, showTaskList() { return this.taskList.slice(0, 2); }, }, methods: { togglePopover() { this.dialogVisible = !this.dialogVisible } }, }; </script> <style lang="less" scoped> .el-popper { z-index: 9999 !important; position: fixed !important; } .label-container { border: 1px solid #ebeef5; border-radius: 4px; padding: 8px 14px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); } .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .label-section { margin-bottom: 8px; span{ margin-bottom: 3px; } } .tag-group { display: flex; gap: 10px; flex-wrap: wrap; } .full-tag-group { display: flex; flex-wrap: wrap; gap: 10px; } </style> <style lang="less" scoped> /* 全局弹窗样式 */ .el-popper.custom-popover { padding: 12px 16px !important; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important; border-radius: 8px !important; border: none !important; /* 标题样式 */ .full-label-section > span { display: block; font-size: 13px; font-weight: 500; color: #606266; margin-bottom: 8px; padding-left: 4px; border-left: 3px solid var(--el-color-primary); } /* 标签组样式 */ .full-tag-group { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; .el-tag { margin: 0 !important; border-radius: 4px; font-size: 12px; padding: 0 8px; height: 24px; line-height: 24px; } } /* 分隔线增强 */ .full-label-section:not(:last-child) { padding-bottom: 12px; border-bottom: 1px dashed #ebeef5; margin-bottom: 12px; } } </style> 为什么以上代码的:append-to-body="true"咩有用,依旧被父元素的overflow-x:hidden影响
07-11
<template> <div id="app"> <div id="container"> <div id="header"> <div class="logo"> <div> <div class="header-title">流程图设计器</div> </div> </div> <div class="button-group"> <button id="save-button" class="button button-save" @click="saveDiagram"><i>💾</i> 保存</button> <button id="reset-button" class="button button-reset" @click="resetDiagram"><i>🔄</i> 重置</button> </div> </div> <div id="canvas-container"> <button id="toggle-sidebar" class="toggle-sidebar" @click="toggleSidebar"> {{ sidebarOpen ? '关闭面板' : '属性面板' }} </button> <div id="canvas"></div> </div> <div id="status-bar"> <div class="status-item"> <div class="status-indicator" :style="statusIndicatorStyle"></div> <span>{{ statusText }}</span> </div> <div class="status-item"> <span>{{ elementCount }} 个元素</span> </div> <div class="status-item"> <span>{{ lastSaveText }}</span> </div> </div> </div> <div id="notification" class="notification" :class="{ show: showNotification, [notificationType]: true }"> {{ notificationMessage }} </div> <div id="sidebar" class="sidebar" :class="{ open: sidebarOpen }"> <h3>元素属性</h3> <div class="properties-group"> <div class="property-item"> <label for="element-name">名称</label> <input type="text" id="element-name" placeholder="输入元素名称" v-model="elementName" @input="updateElementProperties" /> </div> <div class="property-item"> <label for="element-desc">描述</label> <textarea id="element-desc" rows="3" placeholder="输入元素描述" v-model="elementDesc" @input="updateElementProperties" ></textarea> </div> </div> </div> </div> </template> <script> import BpmnJS from 'bpmn-js/dist/bpmn-modeler.development.js' import 'bpmn-js/dist/assets/diagram-js.css' import 'bpmn-js/dist/assets/bpmn-js.css' import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css' export default { name: 'ActivitiDesigner', data() { return { bpmnModeler: null, isModelerReady: false, sidebarOpen: false, showNotification: false, notificationMessage: '', notificationType: '', statusText: '就绪', elementCount: 0, lastSaveText: '未保存', currentElement: null, elementName: '', elementDesc: '', elementBusinessObject: null, } }, computed: { statusIndicatorStyle() { switch (this.statusText) { case '就绪': return { backgroundColor: '#2ecc71' } case '加载中': return { backgroundColor: '#f39c12' } case '保存中': return { backgroundColor: '#3498db' } case '错误': return { backgroundColor: '#e74c3c' } default: return { backgroundColor: '#95a5a6' } } }, }, mounted() { this.initializeModeler() }, methods: { async initializeModeler() { try { this.showNotification = true this.notificationMessage = '正在初始化流程图设计器...' this.notificationType = 'warning' // 创建BPMN模型实例 this.bpmnModeler = new BpmnJS({ container: '#canvas', keyboard: { bindTo: document, }, }) // 监听模型就绪事件 this.bpmnModeler.on('import.done', (event) => { console.log('BPMN模型加载完成') this.isModelerReady = true this.statusText = '就绪' // 更新元素计数 this.updateElementCount() // 显示成功通知 this.showNotificationMessage('流程图加载完成!', 'success') // 监听元素选择事件 this.bpmnModeler.on('element.click', (event) => { this.handleElementSelection(event.element) }) }) // 监听错误事件 this.bpmnModeler.on('error', (err) => { console.error('BPMN模型错误', err) this.isModelerReady = false this.statusText = '错误' this.showNotificationMessage(`模型错误: ${err.message}`, 'error') }) // 监听元素变化事件 this.bpmnModeler.on('element.changed', () => { this.updateElementCount() }) // 创建新流程图 await this.createNewDiagram() } catch (err) { console.error('初始化BPMN模型失败', err) this.showNotificationMessage(`初始化失败: ${err.message}`, 'error') } }, async createNewDiagram() { if (!this.bpmnModeler) return try { this.statusText = '加载中' await this.bpmnModeler.createDiagram() console.log('创建流程图成功') this.lastSaveText = '未保存' this.showNotificationMessage('已创建新流程图', 'success') this.statusText = '就绪' } catch (err) { console.error('创建流程图失败', err) this.showNotificationMessage(`创建流程图失败: ${err.message}`, 'error') this.statusText = '错误' } }, async saveDiagram() { if (!this.bpmnModeler || !this.isModelerReady) { this.showNotificationMessage('模型尚未准备好,请稍后再试', 'warning') return } try { this.statusText = '保存中' // 保存XML const { xml } = await this.bpmnModeler.saveXML({ format: true }) console.log('BPMN XML:', xml) // 在实际应用中,这里可以发送到服务器保存 // await this.saveToServer(xml); // 更新状态 const now = new Date() this.lastSaveText = `最后保存: ${now.toLocaleTimeString()}` // 显示成功通知 this.showNotificationMessage('流程图保存成功!XML内容已输出到控制台', 'success') // 恢复状态 setTimeout(() => { this.statusText = '就绪' }, 1000) } catch (err) { console.error('保存失败', err) this.showNotificationMessage(`保存失败: ${err.message}`, 'error') this.statusText = '错误' } }, resetDiagram() { if (confirm('确定要重置吗?当前内容将丢失。')) { this.createNewDiagram() this.elementName = '' this.elementDesc = '' this.currentElement = null } }, toggleSidebar() { this.sidebarOpen = !this.sidebarOpen }, updateElementCount() { if (!this.bpmnModeler) return try { const elementRegistry = this.bpmnModeler.get('elementRegistry') this.elementCount = elementRegistry ? elementRegistry.getAll().length : 0 } catch (err) { console.error('更新元素计数失败', err) } }, showNotificationMessage(message, type) { this.notificationMessage = message this.notificationType = type this.showNotification = true setTimeout(() => { this.showNotification = false }, 3000) }, handleElementSelection(element) { this.currentElement = element this.elementBusinessObject = element.businessObject console.log(element,'element') // 加载元素属性 this.elementName = this.elementBusinessObject.name || '' this.elementDesc = this.elementBusinessObject.description || '' // 打开属性面板 this.sidebarOpen = true }, updateElementProperties() { if (!this.currentElement || !this.bpmnModeler || !this.elementBusinessObject) return try { const modeling = this.bpmnModeler.get('modeling') // 更新名称 modeling.updateProperties(this.currentElement, { name: this.elementName, description: this.elementDesc, }) this.showNotificationMessage('元素属性已更新', 'success') } catch (err) { console.error('更新元素属性失败', err) this.showNotificationMessage(`更新属性失败: ${err.message}`, 'error') } }, }, } </script> <style scoped> * { box-sizing: border-box; margin: 0; padding: 0; } body, html { height: 100%; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); color: #333; overflow: hidden; } #container { display: flex; flex-direction: column; height: calc(100vh - 150px) ; max-width: 100%; margin: 0 auto; box-shadow: 0 0 30px rgba(0, 0, 0, 0.1); } #header { background: linear-gradient(to right, #2c3e50, #4a6491); color: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); z-index: 10; } .logo { display: flex; align-items: center; gap: 15px; } .logo-icon { font-size: 28px; color: #3498db; } .header-title { font-size: 22px; font-weight: 600; } .header-subtitle { font-size: 14px; opacity: 0.8; margin-top: 3px; } .button-group { display: flex; gap: 12px; } .button { padding: 10px 20px; border: none; border-radius: 5px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.3s ease; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .button:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); } .button:active { transform: translateY(0); } .button-save { background: linear-gradient(to right, #27ae60, #2ecc71); color: white; } .button-reset { background: linear-gradient(to right, #e74c3c, #c0392b); color: white; } .button-export { background: linear-gradient(to right, #3498db, #2980b9); color: white; } #canvas-container { flex: 1; position: relative; overflow: hidden; background: #f8f9fa; } #canvas { height: 100%; width: 100%; } #status-bar { background: #2c3e50; color: #ecf0f1; padding: 8px 20px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; } .status-item { display: flex; align-items: center; gap: 8px; } .status-indicator { width: 10px; height: 10px; border-radius: 50%; background-color: #2ecc71; } .notification { position: fixed; top: 20px; right: 20px; padding: 15px 25px; border-radius: 5px; color: white; font-weight: 500; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); z-index: 1000; opacity: 0; transform: translateX(100%); transition: all 0.4s ease; } .notification.show { opacity: 1; transform: translateX(0); } .notification.success { background: linear-gradient(to right, #27ae60, #2ecc71); } .notification.error { background: linear-gradient(to right, #e74c3c, #c0392b); } .notification.warning { background: linear-gradient(to right, #f39c12, #e67e22); } .sidebar { position: absolute; top: 260px; right: 20px; width: 300px; height: 50%; background: white; box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1); z-index: 5; padding: 20px; overflow-y: auto; display: none; } .sidebar.open { display: inline } .sidebar h3 { margin-bottom: 15px; color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; } .properties-group { margin-bottom: 20px; } .property-item { margin-bottom: 15px; } .property-item label { display: block; margin-bottom: 5px; font-weight: 500; color: #2c3e50; } .property-item input, .property-item textarea, .property-item select { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; } .toggle-sidebar { position: absolute; top: 20px; right: 20px; background: #3498db; color: white; border: none; border-radius: 5px; padding: 8px 15px; cursor: pointer; z-index: 6; } .tools-palette { position: absolute; top: 20px; left: 20px; background: white; border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); padding: 15px; z-index: 5; display: flex; flex-direction: column; gap: 10px; } .tool-btn { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #f8f9fa; border: 1px solid #e0e0e0; cursor: pointer; transition: all 0.2s; } .tool-btn:hover { background: #3498db; color: white; transform: scale(1.1); } .tool-btn.active { background: #3498db; color: white; } </style> 描述没有更新
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值