JavaScript--html标签注意事项回顾大总结

来源:互联网 发布:php <=和=< 编辑:程序博客网 时间:2024/05/25 23:59

1.height:auto和height:100%的区别?

auto是自适应,是随内容的高度而撑开的。100%是根据父级元素的高度来决定的<div style="height:auto;width:100px;float:left;">这个容器的高度是随里面的内容的高度而定</div><div style="height:100%;width:100px;float:right;">这个容器的高度为父级的高度,100px</div> </div>


2.css中元素的auto属性值是什么意思,比如margin:0 auto表示什么?

auto 你可以理解为一种 自动/自适应 的概念 比如 现在项目需要一个宽度为960px的整体布局居中 根据用户浏览器大小不同你将需要使用margin:0 auto;来实现。无论用户浏览器宽度为多少margin:0 auto,意思就是上下边距为0,左右边距为auto,就是自动适应。但是,如果要使用他的话,就必须给标签配上指定的宽度


3.设置字体

font:60px/60px "simhei";的意思是字体大小为60 行高60 字体为黑体


4.no-repeat

background: yellow url("img/3.jpg") no-repeatcss中no-repeat一般用在元素backgroud-repeat的设置中,含义为不平铺;


5.overflow hidden

<!DOCTYPE html>  <html>  <head>      <title>父元素中有overflow:hidden, 子元素absolute不能显示</title>      <style>          .parent{              height:40px;              width:200px;              border:solid 1px black;              position:relative;          }          .sub{              position:absolute;              top:10px;              left:10px;              height:100px;              width:100px;              background-color:red          }          .overHidden{              overflow:hidden;    /* 同样会隐藏position:absolute的子元素 */          }      </style>  </head>  <body>  这个是有overflow:hidden      <div class="parent overHidden">          <div class="sub"></div>      </div>      这个没有      <div class="parent">          <div class="sub"></div>      </div>  </body>  </html>  

这里写图片描述

原创粉丝点击