Maison >interface Web >tutoriel HTML >《HTML5与CSS3基础教程》学习笔记 Three Day - 逆光飞翔23
1、 box-sizing:border-box(让宽度和高度包含内边距和边框)
2、 clear让后面的元素显示在浮动元素的后面
3、 z-index只对只对绝对、固定、相对定位的元素有效
4、 vertical-aligh只用于行内元素
baseline/middle/sub/super/text-top/text-bottom/top/bottom/百分比/值
1、
and (min-width/max-width/resolution:value)” href=”” />
2、
1、
<span style="color: #800000;"> body</span>{<span style="color: #ff0000;"> font-family</span>:<span style="color: #0000ff;">’ pt_sansregular’</span>; }<span style="color: #800000;"> @font-face</span>{<span style="color: #ff0000;"> font-family</span>:<span style="color: #0000ff;"> 'pt_sansregular'</span>;<span style="color: #ff0000;"> src</span>:<span style="color: #0000ff;"> url('PTS55F-webfont.eot')</span>;<span style="color: #ff0000;"> src</span>:<span style="color: #0000ff;"> url('PTS55F-webfont.eot?#iefix') format('embedded-opentype'), url('PTS55F-webfont.woff') format('woff'), url('PTS55F-webfont.ttf') format('truetype')</span>;<span style="color: #ff0000;"> font-weight</span>:<span style="color: #0000ff;"> normal</span>;<span style="color: #ff0000;"> font-style</span>:<span style="color: #0000ff;"> normal</span>; }
1、 渐变背景
1) 默认情况下,线性渐变是从上往下渐变的, 因此在属性值中不需要指定 to bottom
<span style="color: #800000;">background: aqua;//要放在前面 background: linear-gradient(to top right,blue,green); background: linear-gradient(90deg,blue,green);(起点:中上线)</span>
2) 径向渐变
<span style="color: #008000;">/*</span><span style="color: #008000;"> 默认 </span><span style="color: #008000;">*/</span><span style="color: #800000;"> background: red; background: radial-gradient(yellow, red); background: radial-gradient(at top,yellow, red); background: radial-gradient(closest-side at 70px 60px, yellow, lime, red); background: radial-gradient(30px 30px at 65% 70%, yellow, lime, red)</span>
2、 元素设置不透明度
3、 生成内容的效果
<span style="color: #800000;">:before和:after .more:after </span>{<span style="color: #ff0000;"> content</span>:<span style="color: #0000ff;"> " »"</span>; }
4、 使用 sprite 拼合图像
sprite 就是通过 content:" "; 生成的空格的背景图像。将其设置为display: block;,从而可以设置与图标大小匹配的高度和宽度
<span style="color: #800000;">.icon:before </span>{<span style="color: #ff0000;"> background-image</span>:<span style="color: #0000ff;"> url(sprite.png)</span>;<span style="color: #ff0000;"> content</span>:<span style="color: #0000ff;"> " "</span>;<span style="color: #ff0000;">//------------------------------------------------- display</span>:<span style="color: #0000ff;"> block</span>;<span style="color: #ff0000;">// height</span>:<span style="color: #0000ff;"> 16px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> 图标高度 </span><span style="color: #008000;">*/</span><span style="color: #ff0000;"> position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;"> width</span>:<span style="color: #0000ff;"> 16px</span>; <span style="color: #008000;">/*</span><span style="color: #008000;"> 图标宽度 </span><span style="color: #008000;">*/</span> }<span style="color: #800000;"> a[href$=".xls"]:before </span>{<span style="color: #ff0000;"> background-position</span>:<span style="color: #0000ff;"> -17px 0</span>; }<span style="color: #800000;"> a[href$=".docx"]:before </span>{<span style="color: #ff0000;"> background-position</span>:<span style="color: #0000ff;"> -34px 0</span>; }
1、 自定义标记
<span style="color: #800000;">ul</span>{<span style="color: #ff0000;"> list-style</span>:<span style="color: #0000ff;"> none</span>;<span style="color: #ff0000;"> margin-left</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;"> padding-left</span>:<span style="color: #0000ff;"> 0</span>; }<span style="color: #800000;"> li</span>{<span style="color: #ff0000;"> background</span>:<span style="color: #0000ff;"> url(../img/done_square.png) no-repeat 0 .1em</span>;<span style="color: #ff0000;"> padding-left</span>:<span style="color: #0000ff;"> 15px</span>;<span style="color: #ff0000;"> line-height</span>:<span style="color: #0000ff;"> 24px</span>; }
2、 选择列表的起始编号
1) 整个列表编码初始值ol里面增加start=”n”
2) 修改有序列表某个列表编码,影响接下来的列表,在li里面增加value=”n”
3、 控制标记的位置
list-style-position=”inside/outside(默认)”
4、 下拉式导航
HTML:
<span style="color: #0000ff;"><span style="color: #800000;">nav </span><span style="color: #ff0000;">role</span><span style="color: #0000ff;">="navigation"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">ul </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="nav"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="/"</span><span style="color: #0000ff;">></span>Home<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>Products<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">ul </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="subnav"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>Phones<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>Accessories<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></span><span style="color: #800000;">ul</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>Support<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">ul </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="subnav"</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>Community Forum<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>Contact Us<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>How-to Guides<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></span><span style="color: #800000;">ul</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"><span style="color: #800000;">li</span><span style="color: #0000ff;">><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="#"</span><span style="color: #0000ff;">></span>About Us<span style="color: #0000ff;"></span><span style="color: #800000;">a</span><span style="color: #0000ff;">></span><span style="color: #800000;">li</span><span style="color: #0000ff;">></span> <span style="color: #0000ff;"></span><span style="color: #800000;">ul</span><span style="color: #0000ff;">></span> <span style="color: #008000;"><!--</span><span style="color: #008000;"> end .nav </span><span style="color: #008000;">--></span> <span style="color: #0000ff;"></span><span style="color: #800000;">nav</span><span style="color: #0000ff;">></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
CSS:
<span style="color: #008000;">/*</span><span style="color: #008000;"> 子菜单的默认状态 </span><span style="color: #008000;">*/</span><span style="color: #800000;"> .nav .subnav </span>{<span style="color: #ff0000;">left</span>:<span style="color: #0000ff;"> -999em</span>;<span style="color: #008000;">/*</span><span style="color: #008000;"> 将子菜单移出屏幕 </span><span style="color: #008000;">*/</span><span style="color: #ff0000;">position</span>:<span style="color: #0000ff;"> absolute</span>;<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;"> 1000</span>;}<span style="color: #800000;"> a,a:hover </span>{<span style="color: #ff0000;">text-decoration</span>:<span style="color: #0000ff;"> none</span>;}<span style="color: #800000;"> ul </span>{<span style="color: #ff0000;">list-style</span>:<span style="color: #0000ff;"> none</span>;<span style="color: #ff0000;">margin-left</span>:<span style="color: #0000ff;"> 0</span>;<span style="color: #ff0000;">padding-left</span>:<span style="color: #0000ff;"> 0</span>;}<span style="color: #800000;"> .nav </span>{<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> #fff</span>;}<span style="color: #800000;"> .nav>li </span>{<span style="color: #ff0000;">float</span>:<span style="color: #0000ff;"> left</span>;<span style="color: #ff0000;">padding-right</span>:<span style="color: #0000ff;"> 10px</span>;}<span style="color: #800000;"> .nav ul </span>{<span style="color: #ff0000;">background</span>:<span style="color: #0000ff;"> #fff</span>;<span style="color: #ff0000;">z-index</span>:<span style="color: #0000ff;"> 1000</span>;<span style="color: #ff0000;">border-bottom</span>:<span style="color: #0000ff;"> 1px solid #fff</span>;}<span style="color: #800000;"> .nav ul li </span>{<span style="color: #ff0000;">border-bottom</span>:<span style="color: #0000ff;"> 1px solid gray</span>;<span style="color: #ff0000;">line-height</span>:<span style="color: #0000ff;"> 24px</span>;<span style="color: #ff0000;">padding</span>:<span style="color: #0000ff;"> 2px 5px</span>;} <span style="color: #008000;">/*</span><span style="color: #008000;"> 当鼠标停留在父元素li上时子菜单的状态 </span><span style="color: #008000;">*/</span><span style="color: #800000;"> .nav li:hover .subnav </span>{<span style="color: #ff0000;">left</span>:<span style="color: #0000ff;"> auto</span>;<span style="color: #008000;">/*</span><span style="color: #008000;"> 让子菜单回到自然状态 </span><span style="color: #008000;">*/</span>}