💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# CSS与CSS3 定位 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> position<span class="token2">:</span> absolute<span class="token2">;</span><span class="token6">//脱离文档 绝对定位</span> relative 相对定位 fixeld 不滚动 static 默认 z<span class="token">-</span>index<span class="token2">:</span> <span class="token3">1</span><span class="token2">;</span>层关系 top<span class="token2">:</span> auto<span class="token2">;</span> left<span class="token2">:</span> auto<span class="token2">;</span> right<span class="token2">:</span> auto<span class="token2">;</span> bottom<span class="token2">:</span> auto<span class="token2">;</span> <span class="token2">}</span> ``` ``` 布局 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> display<span class="token2">:</span>inline<span class="token2">;</span>默认内联元素 none 隐藏 block 块元素 inline<span class="token">-</span>block 内联块元素 float<span class="token2">:</span>none<span class="token2">;</span>不浮动 left right clear<span class="token2">:</span> both<span class="token2">;</span>清除浮动 visibility<span class="token2">:</span> visible<span class="token2">;</span>对象可视 hidden对象隐藏 overflow<span class="token2">:</span> visible<span class="token2">;</span>溢出内容不作处理<span class="token2">,</span>可能超出容器 hidden隐藏不出现滚动条 scroll滚动 auto溢出出现滚动<span class="token2">,</span>不溢出没有 overflow<span class="token">-</span>x<span class="token2">:</span> visible<span class="token2">;</span> overflow<span class="token">-</span>y<span class="token2">:</span> visible<span class="token2">;</span> 同上<span class="token2">,</span>表示水平方向和垂直方向 <span class="token2">}</span> ``` ``` 尺寸,支持像素 em 百分比等 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> width<span class="token2">:</span> auto<span class="token2">;</span> <span class="token3">12</span>px <span class="token3">10</span><span class="token">%</span> min<span class="token">-</span>width<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> max<span class="token">-</span>width<span class="token2">:</span> none<span class="token2">;</span>没有最大宽度 height<span class="token2">:</span> auto<span class="token2">;</span> min<span class="token">-</span>height<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> max<span class="token">-</span>height<span class="token2">:</span> none<span class="token2">;</span> <span class="token2">}</span> ``` ``` 内外补白 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> margin<span class="token2">:</span> auto<span class="token2">;</span>可以负值 margin<span class="token">-</span>top<span class="token2">:</span> auto<span class="token2">;</span>上 margin<span class="token">-</span>bottom<span class="token2">:</span> auto<span class="token2">;</span>下 margin<span class="token">-</span>left<span class="token2">:</span> auto<span class="token2">;</span> margin<span class="token">-</span>right<span class="token2">:</span> auto<span class="token2">;</span> padding<span class="token2">:</span> <span class="token3">1</span>px<span class="token2">;</span>不可以负值<span class="token2">,</span>也没有自动 padding<span class="token">-</span>bottom<span class="token2">:</span><span class="token3">1</span><span class="token">%</span><span class="token2">;</span> padding<span class="token">-</span>top<span class="token2">:</span> inherit<span class="token2">;</span> padding<span class="token">-</span>left<span class="token2">:</span> inherit<span class="token2">;</span> padding<span class="token">-</span>right<span class="token2">:</span><span class="token3">1</span>px<span class="token2">;</span> <span class="token2">}</span> ``` ``` 边框 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> border<span class="token2">:</span> <span class="token3">1</span>px solid #fff<span class="token2">;</span> border<span class="token">-</span>width<span class="token2">:</span> <span class="token3">1</span>px<span class="token2">;</span> border<span class="token">-</span>style<span class="token2">:</span> solid<span class="token2">;</span>实线 none<span class="token2">;</span>没有边框<span class="token2">,</span>默认值 dotted<span class="token2">;</span>点状 dashed<span class="token2">;</span>虚线 border<span class="token">-</span>color<span class="token2">:</span> #fff<span class="token2">;</span> border<span class="token">-</span>top<span class="token2">:</span> <span class="token3">1</span>px solid #fff<span class="token2">;</span> border<span class="token">-</span>bottom<span class="token2">:</span> <span class="token">!</span>important<span class="token2">;</span> border<span class="token">-</span>left<span class="token2">:</span> <span class="token">!</span>important<span class="token2">;</span> border<span class="token">-</span>right<span class="token2">:</span> <span class="token">!</span>important<span class="token2">;</span> <span class="token2">}</span> ``` ``` 背景 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> background<span class="token2">:</span><span class="token1">url</span><span class="token2">(</span>test1<span class="token2">.</span>jpg<span class="token2">)</span> no<span class="token">-</span>repeat scroll <span class="token3">0</span><span class="token">%</span> <span class="token3">0</span><span class="token">%</span><span class="token2">;</span> background<span class="token">-</span>color<span class="token2">:</span> transparent<span class="token2">;</span>默认透明 background<span class="token">-</span>image<span class="token2">:</span> none<span class="token2">;</span>无图 <span class="token1">url</span><span class="token2">(</span><span class="token3">1.</span>img<span class="token2">)</span> background<span class="token">-</span>repeat<span class="token2">:</span> repeat<span class="token2">;</span>平铺 no<span class="token">-</span>repeat 不平铺 repeat<span class="token">-</span>x <span class="token2">;</span>repeat<span class="token">-</span>y 横纵平铺 background<span class="token">-</span>attachment<span class="token2">:</span> scroll<span class="token2">;</span> 滚动 fixed<span class="token2">;</span>固定 background<span class="token">-</span>position<span class="token2">:</span> <span class="token3">0</span><span class="token">%</span> <span class="token3">0</span><span class="token">%</span><span class="token2">;</span> left center right top bottom<span class="token2">;</span> background<span class="token">-</span>origin<span class="token2">:</span> padding<span class="token">-</span>box<span class="token2">;</span>背景从content显示 border<span class="token">-</span>box<span class="token2">;</span>从border区域开始 padding<span class="token">-</span>box<span class="token2">;</span>从padding开始 background<span class="token">-</span>clip<span class="token2">:</span> border<span class="token">-</span>box<span class="token2">;</span>从padding向外剪裁 border<span class="token">-</span>box<span class="token2">;</span>从border开始<span class="token2">,</span>不含 content<span class="token">-</span>box<span class="token2">;</span>从content开始剪切 text<span class="token2">;</span>从内容开始 background<span class="token">-</span>size<span class="token2">:</span> auto<span class="token2">;</span>背景大小自动 cover<span class="token2">;</span>等比缩放完全覆盖<span class="token2">,</span>会出容器 contain<span class="token2">;</span>等比缩放宽高和容器相等<span class="token2">,</span>始终在容器内 <span class="token2">}</span> ``` ``` 颜色 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> color<span class="token2">:</span> #FFF<span class="token2">;</span>文本颜色 opacity<span class="token2">:</span> <span class="token3">1</span><span class="token2">;</span><span class="token3">1</span>是不透明 <span class="token3">0</span>完全透明 取值<span class="token3">0.0</span><span class="token">-</span><span class="token3">1</span> <span class="token2">}</span> ``` ``` 字体 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> font<span class="token2">:</span> <span class="token3">12</span>px Simsun<span class="token2">,</span>arial<span class="token2">,</span>sans<span class="token">-</span>serif<span class="token2">;</span> font<span class="token">-</span>style<span class="token2">:</span> normal<span class="token2">;</span>字体正常 italic<span class="token2">;</span>斜体 font<span class="token">-</span>weight<span class="token2">:</span> normal<span class="token2">;</span>正常相当于<span class="token3">400</span> bold 粗体相当于<span class="token3">700</span> bolder 特粗 相当于b strong font<span class="token">-</span>size<span class="token2">:</span><span class="token3">12</span>px<span class="token2">;</span> font<span class="token">-</span>family<span class="token2">:</span> arial<span class="token2">;</span> <span class="token2">}</span> ``` ``` 文本 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> text<span class="token">-</span>transform<span class="token2">:</span> none<span class="token2">;</span> capitalize<span class="token2">;</span>首字母大写 uppercase<span class="token2">;</span>转换大写 lowercase<span class="token2">;</span>转小写 white<span class="token">-</span>space<span class="token2">:</span> normal<span class="token2">;</span>空格处理默认 pre<span class="token">-</span>wrap<span class="token2">;</span>不合并空白<span class="token2">,</span>边界处换行 nowrap<span class="token2">;</span>强制同一行显示<span class="token2">,</span>合并多余空白<span class="token2">,</span>直到br word<span class="token">-</span><span class="token5">break</span><span class="token2">:</span> normal<span class="token2">;</span>换行 <span class="token5">break</span><span class="token">-</span>all<span class="token2">;</span> word<span class="token">-</span>wrap<span class="token2">:</span> normal<span class="token2">;</span> <span class="token5">break</span><span class="token">-</span>word<span class="token2">;</span>边界处换行 text<span class="token">-</span>align<span class="token2">:</span> center<span class="token2">;</span>left<span class="token2">;</span>right<span class="token2">;</span> text<span class="token">-</span>indent<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span>缩进 vertical<span class="token">-</span>align<span class="token2">:</span> baseline<span class="token2">;</span> sub<span class="token2">;</span>下标 super<span class="token2">;</span>上标 middle<span class="token2">;</span>居中 line<span class="token">-</span>height<span class="token2">:</span> normal<span class="token2">;</span>行高 <span class="token2">}</span> ``` ``` 列表样式 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> list<span class="token">-</span>style<span class="token2">:</span>disc outside none<span class="token2">;</span> list<span class="token">-</span>style<span class="token">-</span>image<span class="token2">:</span> none<span class="token2">;</span>不指定图像 list<span class="token">-</span>style<span class="token">-</span>position<span class="token2">:</span> outside<span class="token2">;</span>文本以外 inside<span class="token2">;</span>文本以内 list<span class="token">-</span>style<span class="token">-</span>type<span class="token2">:</span> disc<span class="token2">;</span>实心圆 circle<span class="token2">;</span>空心圆 square<span class="token2">;</span>实心方块 decimal<span class="token2">;</span>数字 none<span class="token2">;</span>不使用 <span class="token2">}</span> ``` ``` 表格样式 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> border<span class="token">-</span>collapse<span class="token2">:</span> collapse<span class="token2">;</span>合并边框 <span class="token2">}</span> ``` ``` 用户界面 ``` <pre class="calibre14">``` <span class="token2">.</span>c<span class="token2">{</span> text<span class="token">-</span>overflow<span class="token2">:</span> clip<span class="token2">;</span>文本溢出不显示<span class="token2">.</span><span class="token2">.</span><span class="token2">.</span> ellipsis<span class="token2">;</span>显示 outline<span class="token2">:</span> none<span class="token2">;</span>轮廓样式无轮廓 cursor<span class="token2">:</span> pointer<span class="token2">;</span>手 move移动 支持<span class="token1">url</span><span class="token2">(</span><span class="token2">)</span> box<span class="token">-</span>sizing<span class="token2">:</span> content<span class="token">-</span>box<span class="token2">;</span>盒子padding和border不包括在宽高内 border<span class="token">-</span>box<span class="token2">;</span>包含内<span class="token2">;</span> user<span class="token">-</span>select<span class="token2">:</span>text<span class="token2">;</span>可以选择文本 none<span class="token2">;</span>文本不能选择 <span class="token2">}</span> ``` ``` 选择 ``` <pre class="calibre16">``` ul<span class="token">></span>li<span class="token2">{</span> <span class="token6">//子选择器</span> <span class="token2">}</span> ul li<span class="token2">{</span> <span class="token6">//包含选择</span> <span class="token2">}</span> p<span class="token">+</span>p<span class="token2">{</span> <span class="token6">//相邻选择</span> <span class="token2">}</span> p<span class="token">~</span>p<span class="token2">{</span> <span class="token6">//兄弟选择</span> <span class="token2">}</span> input<span class="token2">[</span>type<span class="token">=</span><span class="token4">"text"</span><span class="token2">]</span><span class="token2">{</span><span class="token2">{</span> <span class="token6">//属性选择</span> <span class="token2">}</span> a<span class="token2">:</span>link<span class="token2">{</span> <span class="token2">}</span> a<span class="token2">:</span>visited<span class="token2">{</span> <span class="token2">}</span> a<span class="token2">:</span>hover<span class="token2">{</span> <span class="token2">}</span> a<span class="token2">:</span>active<span class="token2">{</span> <span class="token2">}</span> a<span class="token2">:</span>focus<span class="token2">{</span> <span class="token2">}</span> ul li<span class="token2">:</span>first<span class="token">-</span>child<span class="token2">{</span> <span class="token6">//第一个</span> <span class="token2">}</span> ul li<span class="token2">:</span>last<span class="token">-</span>child<span class="token2">{</span> <span class="token6">//最后一个</span> <span class="token2">}</span> ``` ```