border:1px引起的盒模型塌陷问题解决方法
来源:互联网 发布:到印度做软件 编辑:程序博客网 时间:2024/06/16 13:32
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .main { margin: 100px auto; height: 173px; width: 100%; background: url(bottom_bg_img.png) top center no-repeat; } .mains { width: 1200px; height: 173px; margin: 0 auto; border: 1px solid red;/*注释掉这一行看看*/ text-align: center; } .mains img { display: block; margin: -100px auto; } </style> </head> <body> <div class="main"> <div class="mains"> <img src="rocket_icon.png" /> </div> </div> </body></html>
border: 1px solid red;/注释掉这一行看看/
解决方法1
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .main { margin: 100px auto; height: 173px; width: 100%; background: url(bottom_bg_img.png) top center no-repeat; } .mains { width: 1200px; height: 173px; margin: 0 auto; border: 1px solid red; text-align: center; } .mains img { position: absolute; margin-top: -100px; transform:translateX(-50%) ; } </style> </head> <body> <div class="main"> <div class="mains"> <img src="rocket_icon.png" /> </div> </div> </body></html>
解决方法2
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .main { margin:0px auto; height: 273px; width: 100%; background: url(bottom_bg_img.png) bottom center no-repeat; } .mains { width: 1200px; height: 273px; margin: 0 auto; border: 1px solid red; } .mains img { display: block; margin: 0 auto; } </style> </head> <body> <div class="main"> <div class="mains"> <img src="rocket_icon.png" /> </div> </div> </body></html>
0 0
- border:1px引起的盒模型塌陷问题解决方法
- CSS盒模型--边框设置:border: 1px solid red(像素 样式 颜色 ),border-bottom:1px dotted #ccc
- 高分辨率下的1px border 实现方法
- 移动端border为1px的设置方法
- 清除浮动引起的高度塌陷的7种方法
- iphone上实现1px的border
- 盒模型&&外边距塌陷
- 最简单的border为1px的表格源代码
- 实现真正的1px的边框 border
- 如何在移动端设置1px的border
- 浮动涉及到的高度塌陷问题解决办法。
- 解决元素塌陷的方法
- 真正的盒模型-border-box
- css中float引起父元素的高度塌陷
- 网站写代码时候lif浮动引起的ul塌陷
- 解决由float引起的“高度塌陷”问题
- css 实现 0.5 px 的 border
- 1px问题解决方案
- Linux基本命令练习(2)
- C语言学习7
- 日记本
- 【杭电】[1285]确定比赛名次
- coreData -- 拖入其他程序的dataModel文件 导致崩溃
- border:1px引起的盒模型塌陷问题解决方法
- Python编码问题的解决方案总结
- Objective-C中分类 (category)和扩展(Extension)以及继承(inherit)
- js创建对象(无参的构造函数)
- hdfs命令
- 数据结构——实现最大堆
- 基础数据类型
- HDU1712 ACboy needs your help
- Binary Search Tree (BST)