关于HTML布局之计算器(div+css)_html/css_WEB-ITnose和html设计计算器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于1.DIV+CSS常用的Html网页布
关于HTML布局之计算器(div+css)_html/css_WEB-ITnose和html设计计算器的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于1.DIV+CSS常用的Html网页布局代码_html/css_WEB-ITnose、css + div 布局之 CSS盒模型 外边距合并问题_html/css_WEB-ITnose、CSS 完美DIV+CSS布局_html/css_WEB-ITnose、CSS 嵌套DIV布局_html/css_WEB-ITnose等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- HTML布局之计算器(div+css)_html/css_WEB-ITnose(html设计计算器)
- 1.DIV+CSS常用的Html网页布局代码_html/css_WEB-ITnose
- css + div 布局之 CSS盒模型 外边距合并问题_html/css_WEB-ITnose
- CSS 完美DIV+CSS布局_html/css_WEB-ITnose
- CSS 嵌套DIV布局_html/css_WEB-ITnose
HTML布局之计算器(div+css)_html/css_WEB-ITnose(html设计计算器)
纯布局, 没有功能实现, 代码多但是不难, 可以作为参考.
代码示例:
html(div)代码:
<title>计算器</title><meta charset="utf-8"><meta name="keywords" content="keyword1,keyword2,keyword3"><meta name="description" content="this is my page"><meta name="content-type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="css/layout.css"><a href="Main.html">返回主页</a> <div id="container"> <div id="title"> <div id="image"><img src="Image/image.png" alt="HTML布局之计算器(div+css)_html/css_WEB-ITnose" ></div> <div id="word"> <p>计算器</p> <p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1"rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p> </div> <div id="select"> <div id="min"><img src="Image/min.png" alt="HTML布局之计算器(div+css)_html/css_WEB-ITnose" ></div> <div id="max"><img src="Image/max.png" alt="HTML布局之计算器(div+css)_html/css_WEB-ITnose" ></div> <div id="off"><img src="Image/off.png" alt="HTML布局之计算器(div+css)_html/css_WEB-ITnose" ></div> </div> </div> <div id="main"> <div id="menu"> <p>查看(V)</p> <div></div> <p>编辑(E)</p> <div></div> <p>帮助(H)</p> </div> <div id="frame"><img src="Image/frame.png" alt="HTML布局之计算器(div+css)_html/css_WEB-ITnose" ></div> <!-- 下面是按键 --> <div id="button"> <div><p>MC</p></div> <div></div> <div><p>MR</p></div> <div></div> <div><p>MS</p></div> <div></div> <div><p>M+</p></div> <div></div> <div><p>M-</p></div> <div><p>←</p></div> <div></div> <div><p>CE</p></div> <div></div> <div><p>C</p></div> <div></div> <div><p>±</p></div> <div></div> <div><p>√</p></div> <div><p>7</p></div> <div></div> <div><p>8</p></div> <div></div> <div><p>9</p></div> <div></div> <div><p>/</p></div> <div></div> <div><p>%</p></div> <div><p>4</p></div> <div></div> <div><p>5</p></div> <div></div> <div><p>6</p></div> <div></div> <div><p>*</p></div> <div></div> <div><p>1/x</p></div> <div><p>1</p></div> <div></div> <div><p>2</p></div> <div></div> <div><p>3</p></div> <div></div> <div><p>-</p></div> <div></div> <div><p>=</p></div> <div><p>0</p></div> <div></div> <div><p>.</p></div> <div></div> <div><p>+</p></div> </div> </div> </div>
CSS代码:
@CHARSET "UTF-8";#container{ position: absolute; top: 50%; left: 50%; margin: -161px -114px; width: 228px; height: 322px; border: 1px black solid; background: #e6e6fa; }#title{ width: 100%; height: 30px; background: #e6e6fa;}#image{ float: left; width: 14px; height: 17px; margin-top: 6px; margin-left: 10px;}#word{ margin-top: -8px; !important; float: left; width: 60px; height: 20px;}#word p{ font-size: 14px; text-align: center;}#select{ float: right; width: 107px; height: 15px; margin-right: 8px;}#min{ float: left; width: 30px; height: 18px;}#max{ float: left; width: 30px; height: 18px;}#off{ float: right; width: 47px; height: 18px;}#main{ width: 212px; height: 284px; margin-left: 8px; overflow: hidden;}#menu{ float: left; width: 212px; height: 20px; background: #dcdcdc;}#menu p{ float: left; font-size: 15px; margin-top: 1px; margin-left: 5px;}.block{ float: left; width: 15px; height: 20px;}#frame{ float: left; width: 190px; height: 48px; margin-top: 10px; margin-left: 3px;}#button{ float: left; width: 190px; height: 180px; margin-left: 11px;}.smallbutton{ float: left; width: 34px; height: 25px; margin-top: 5px; background: #dcdcdc}.bigbuttonY{ float: right; width: 34px; height: 55px; background: #dcdcdc; margin-top: 5px;}.bigbuttonX{ float: left; width: 73px; height: 25px; background: #dcdcdc; margin-top: 5px;}.buttonblock{ float: left; width: 5px; height: 25px;}#button p{ text-align: center; margin-top: 3px;}
运行结果:
1.DIV+CSS常用的Html网页布局代码_html/css_WEB-ITnose
单行一列
以下是引用片段:
body { margin: 0px; padding: 0px; text-align: center; }
#content { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
两行一列
以下是引用片段:
body { margin: 0px; padding: 0px; text-align: center;}
#content-top { margin-left:auto; margin-right:auto; width: 400px; width: 370px;}
#content-end {margin-left:auto; margin-right:auto; width: 400px; width: 370px;}
三行一列
以下是引用片段:
body { margin: 0px; padding: 0px; text-align: center; }
#content-top { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
#content-mid { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
#content-end { margin-left:auto; margin-right:auto; width: 400px; width: 370px; }
单行两列
以下是引用片段:
#bodycenter { width: 700px;margin-right: auto; margin-left: auto;overflow: auto; }
#bodycenter #dv1 {float: left;width: 280px;}
#bodycenter #dv2 {float: right;width: 410px;}
立即学习“前端免费学习笔记(深入)”;
两行两列
以下是引用片段:
#header{ width: 700px; margin-right: auto;margin-left: auto; overflow: auto;}
#bodycenter { width: 700px; margin-right: auto; margin-left: auto; overflow: auto; }
#bodycenter #dv1 { float: left; width: 280px;}
#bodycenter #dv2 { float: right;width: 410px;}
三行两列
以下是引用片段:
#header{ width: 700px;margin-right: auto; margin-left: auto; }
#bodycenter {width: 700px; margin-right: auto; margin-left: auto; }
#bodycenter #dv1 { float: left;width: 280px;}
#bodycenter #dv2 { float: right; width: 410px;}
#footer{ width: 700px; margin-right: auto; margin-left: auto; overflow: auto; }
单行三列
绝对定位
以下是引用片段:
#left { position: absolute; top: 0px; left: 0px; width: 120px; }
#middle {margin: 20px 190px 20px 190px; }
#right {position: absolute;top: 0px; right: 0px; width: 120px;}
float定位一
xhtml:
以下是引用片段:
CSS:
以下是引用片段:
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
float定位二
xhtml:
以下是引用片段:
This is the main content.
This is the left sidebar.
This is the right sidebar.
CSS:
以下是引用片段:
body {margin: 0;padding-left: 200px;padding-right: 190px;min-width: 240px;}
.column {position: relative;float: left;}
#center {width: 100%;}
#left {width: 180px; right: 240px;margin-left: -100%;}
#right {width: 130px;margin-right: -100%;}
两行三列
xhtml:以下是引用片段:
CSS:
以下是引用片段:
#header{width:100%; height:auto;}
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
三行三列
xhtml:
以下是引用片段:
CSS:
以下是引用片段:
#header{width:100%; height:auto;}
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
#footer{width:100%; height:auto;}
css + div 布局之 CSS盒模型 外边距合并问题_html/css_WEB-ITnose
问题表述:
在经过我用谷歌浏览器的查看DOM 结果后我发现还是因为一些浏览器的代码渲染差别造成的,我就到http://w3school.com.cn/ 上寻求解释。终于在这里
我看出了问题的存在(盒子没有获得 haslayout 造成 margin-top无效),我到百度上又搜索了一下别人是不是也遇到了同样的问题,综合各家说法我最后总结出以下几个问题的重点:
a、全部都为正值,取最大者;
b、不全是正值,则都取绝对值,然后用正值减去最大值;
c、没有正值,则都取绝对值,然后用0减去最大值。
注意:相邻的盒模型可能由DOM元素动态产生并没有相邻或继承关系。 相邻的盒模型中,如果其中的一个是浮动的(floated),垂直margin不会被折叠,甚至一个浮动的盒模型和它的子元素之间也是这样。 设置了overflow属性的元素和它的子元素之间的margin不会被折叠(overflow取值为visible除外)。 设置了绝对定位(position:absolute)的盒模型,垂直margin不会被折叠,甚至和他们的子元素之间也是一样。 设置了display:inline-block的元素,垂直margin不会被折叠,甚至和他们的子元素之间也是一样。 如果一个盒模型的上下margin相邻,这时它的margin可能折叠覆盖(collapse through)它。在这种情况下,元素的位置(position)取决于它的相邻元素的margin是否被折叠。
a、如果元素的margin和它的父元素的margin-top折叠在一起,盒模型border-top的边界定义和它的父元素相同。
b、另外,任意元素的父元素不参与margin的折叠,或者说只有父元素的margin-bottom是参与计算的。如果元素的border-top非零,那么元素的border-top边界位置和原来一样。
一个应用了清除操作的元素的margin-top绝不会和它的块级父元素的margin-bottom折叠。
注意,那些已经被折叠覆盖的元素的位置对其他已经被折叠的元素的位置没有任何影响;只有在对这些元素的子元素定位时,border-top边界位置才是必需的。 根元素的垂直margin不会被折叠。 解决方案:
在父层div加上:overflow:hidden; 把margin-top外边距改成padding-top内边距; 父元素产生边距重叠的边有不为 0 的 padding 或宽度不为 0 且 style 不为 none 的 border
父层div加: padding-top: 1px;
让父元素生成一个 block formating context,以下属性可以实现 * float: left/right * position: absolute * display: inline-block/table-cell(或其他 table 类型) * overflow: hidden/auto 父层div加:position: absolute;
就此截住!
注:本文的总结也是网上其他前辈的辛劳我这里知识借用了一下,在此做出声明:我参考的博文地址有:
http://blog.sina.com.cn/s/blog_6bec36f9010110w9.html
http://hi.baidu.com/jmtbai/blog/item/a91a136ca2d098eb42169456.html
立即学习“前端免费学习笔记(深入)”;
还有一点是我觉得有必要说一下的就是这个效果在IE里面出现在谷歌里面不出现,我找到了一点资料是关于IE浏览器关于渲染的原理:
hasLayout:http://baike.baidu.com/view/2945869.htm
CSS 完美DIV+CSS布局_html/css_WEB-ITnose
--技巧 先对每个较大div的css样式设置 border:solid 1px blue 整体布局调整完再去掉
1.先弄最外框的
View Code
2.马上加上CSS
View Code
3.分析布局左右结构
View Code
4.加上CSS
立即学习“前端免费学习笔记(深入)”;
View Code
5.分析为 左-右-下 结构
View Code
6.加上CSS
View Code
7.左部 又分为上下2个DIV
View Code
8.加上CSS
View Code
9.填充每个DIV内容
10.全部代码
View Code
CSS 嵌套DIV布局_html/css_WEB-ITnose
嵌套div布局,会牵扯到css的position属性
如果内层DIV将position属性设置为absolute,并设置left,和top等属性,还需要考虑外层DIV的position属性设置。
absolute:absolute绝对定位,直接指定top、left、right、bottom。有意思的是绝对定位也是“相对”的。它的坐标是相对其容器来说的。容器又是什么呢,容器就是离元素最近的一个定位好的“祖先”,定位好的意思就是其Position是absolute或fixed或relative。如果没有这个容器,那就使用浏览器初始的,也就是body或者html元素。标准是说只需要指定left和right,width可以自动根据容器宽度计算出来,可惜ie不支持。
立即学习“前端免费学习笔记(深入)”;
关于HTML布局之计算器(div+css)_html/css_WEB-ITnose和html设计计算器的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于1.DIV+CSS常用的Html网页布局代码_html/css_WEB-ITnose、css + div 布局之 CSS盒模型 外边距合并问题_html/css_WEB-ITnose、CSS 完美DIV+CSS布局_html/css_WEB-ITnose、CSS 嵌套DIV布局_html/css_WEB-ITnose的相关信息,请在本站寻找。
本文标签: