企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# css3 - hover动画 ``` <pre class="calibre14">``` <span class="token2">.</span>hover<span class="token">-</span>ani <span class="token2">{</span> display<span class="token2">:</span> inline<span class="token">-</span>block<span class="token2">;</span> position<span class="token2">:</span> relative<span class="token2">;</span> color<span class="token2">:</span> #<span class="token3">33151</span>e<span class="token2">;</span> <span class="token2">}</span> <span class="token2">.</span>hover<span class="token">-</span>ani<span class="token2">:</span><span class="token2">:</span>after <span class="token2">{</span> content<span class="token2">:</span> <span class="token4">''</span><span class="token2">;</span> position<span class="token2">:</span> absolute<span class="token2">;</span> width<span class="token2">:</span> <span class="token3">100</span><span class="token">%</span><span class="token2">;</span> transform<span class="token2">:</span> <span class="token1">scaleX</span><span class="token2">(</span><span class="token3">0</span><span class="token2">)</span><span class="token2">;</span> height<span class="token2">:</span> <span class="token3">2</span>px<span class="token2">;</span> bottom<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> left<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> background<span class="token">-</span>color<span class="token2">:</span> #<span class="token3">33151</span>e<span class="token2">;</span> transform<span class="token">-</span>origin<span class="token2">:</span> bottom right<span class="token2">;</span> transition<span class="token2">:</span> transform <span class="token3">0.25</span>s ease<span class="token">-</span>out<span class="token2">;</span> <span class="token2">}</span> <span class="token2">.</span>hover<span class="token">-</span>ani<span class="token2">:</span>hover<span class="token2">:</span><span class="token2">:</span>after <span class="token2">{</span> transform<span class="token2">:</span> <span class="token1">scaleX</span><span class="token2">(</span><span class="token3">1</span><span class="token2">)</span><span class="token2">;</span> transform<span class="token">-</span>origin<span class="token2">:</span> bottom left<span class="token2">;</span> <span class="token2">}</span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"hover-ani"</span><span class="token">></span>移动到内容出现动画<span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` - 竖线 ``` <pre class="calibre14">``` <span class="token2">.</span>shortcut<span class="token2">{</span> display<span class="token2">:</span> flex<span class="token2">;</span> <span class="token2">}</span> li <span class="token2">{</span> list<span class="token">-</span>style<span class="token">-</span>type<span class="token2">:</span> none<span class="token2">;</span> margin<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> padding<span class="token2">:</span> <span class="token3">0</span> <span class="token3">0.75</span>rem<span class="token2">;</span> <span class="token2">}</span> li<span class="token2">:</span><span class="token1">not</span><span class="token2">(</span><span class="token2">:</span>last<span class="token">-</span>child<span class="token2">)</span> <span class="token2">{</span> border<span class="token">-</span>right<span class="token2">:</span> <span class="token3">1</span>px solid #d2d5e4<span class="token2">;</span> <span class="token2">}</span> <span class="token"><</span>ul class<span class="token">=</span><span class="token4">"shortcut"</span><span class="token">></span> <span class="token"><</span>li<span class="token">></span>首页<span class="token"><</span><span class="token">/</span>li<span class="token">></span> <span class="token"><</span>li<span class="token">></span>关于<span class="token"><</span><span class="token">/</span>li<span class="token">></span> <span class="token"><</span>li<span class="token">></span>联系<span class="token"><</span><span class="token">/</span>li<span class="token">></span> <span class="token"><</span><span class="token">/</span>ul<span class="token">></span> ``` ``` - 小三角 bottom向上 top向下 第二个left向右 right向左 ``` <pre class="calibre14">``` <span class="token2">.</span>triangle <span class="token2">{</span> width<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> height<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> border<span class="token">-</span>top<span class="token2">:</span> <span class="token3">10</span>px solid #<span class="token3">333</span><span class="token2">;</span> border<span class="token">-</span>left<span class="token2">:</span> <span class="token3">10</span>px solid transparent<span class="token2">;</span> border<span class="token">-</span>right<span class="token2">:</span> <span class="token3">10</span>px solid transparent<span class="token2">;</span> <span class="token2">}</span> <span class="token2">.</span>triangle <span class="token2">{</span> width<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> height<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> border<span class="token">-</span>top<span class="token2">:</span> <span class="token3">10</span>px solid transparent<span class="token2">;</span> border<span class="token">-</span>bottom<span class="token2">:</span> <span class="token3">10</span>px solid transparent<span class="token2">;</span> border<span class="token">-</span>left<span class="token2">:</span> <span class="token3">10</span>px solid #<span class="token3">333</span><span class="token2">;</span> <span class="token2">}</span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"triangle"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` - 文本截断 ``` <pre class="calibre14">``` <span class="token2">.</span>ell<span class="token">-</span>text <span class="token2">{</span> overflow<span class="token2">:</span> hidden<span class="token2">;</span> white<span class="token">-</span>space<span class="token2">:</span> nowrap<span class="token2">;</span> text<span class="token">-</span>overflow<span class="token2">:</span> ellipsis<span class="token2">;</span> width<span class="token2">:</span> <span class="token3">200</span>px<span class="token2">;</span> <span class="token2">}</span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"ell-text"</span><span class="token">></span>测试文本截断显示三个点测试文本截断显示三个点<span class="token2">.</span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` - loading ``` <pre class="calibre14">``` @keyframes donut<span class="token">-</span>spin <span class="token2">{</span> <span class="token3">0</span><span class="token">%</span> <span class="token2">{</span> transform<span class="token2">:</span> <span class="token1">rotate</span><span class="token2">(</span><span class="token3">0</span>deg<span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span> <span class="token3">100</span><span class="token">%</span> <span class="token2">{</span> transform<span class="token2">:</span> <span class="token1">rotate</span><span class="token2">(</span><span class="token3">360</span>deg<span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span> <span class="token2">}</span> <span class="token2">.</span>loading <span class="token2">{</span> display<span class="token2">:</span> inline<span class="token">-</span>block<span class="token2">;</span> border<span class="token2">:</span> <span class="token3">3</span>px solid <span class="token1">rgba</span><span class="token2">(</span><span class="token3">0</span><span class="token2">,</span> <span class="token3">0</span><span class="token2">,</span> <span class="token3">0</span><span class="token2">,</span> <span class="token3">0.2</span><span class="token2">)</span><span class="token2">;</span> border<span class="token">-</span>left<span class="token">-</span>color<span class="token2">:</span> #<span class="token3">333</span><span class="token2">;</span> border<span class="token">-</span>radius<span class="token2">:</span> <span class="token3">50</span><span class="token">%</span><span class="token2">;</span> width<span class="token2">:</span> <span class="token3">25</span>px<span class="token2">;</span> height<span class="token2">:</span> <span class="token3">25</span>px<span class="token2">;</span> animation<span class="token2">:</span> donut<span class="token">-</span>spin <span class="token3">1</span>s linear infinite<span class="token2">;</span> <span class="token2">}</span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"loading"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` - 美化表格 ``` <pre class="calibre14">``` <span class="token2">.</span>table <span class="token2">{</span>width<span class="token2">:</span><span class="token3">90</span><span class="token">%</span><span class="token2">;</span>background<span class="token2">:</span>#ddd<span class="token2">;</span> margin<span class="token2">:</span> <span class="token3">10</span>px auto<span class="token2">;</span>border<span class="token">-</span>collapse<span class="token2">:</span>collapse<span class="token2">;</span><span class="token2">}</span> <span class="token2">.</span>table th<span class="token2">,</span> <span class="token2">.</span>table td <span class="token2">{</span>height<span class="token2">:</span><span class="token3">25</span>px<span class="token2">;</span>line<span class="token">-</span>height<span class="token2">:</span><span class="token3">25</span>px<span class="token2">;</span>text<span class="token">-</span>align<span class="token2">:</span>center<span class="token2">;</span>border<span class="token2">:</span><span class="token3">1</span>px solid #ddd<span class="token2">;</span><span class="token2">}</span> <span class="token2">.</span>table th <span class="token2">{</span>background<span class="token2">:</span>#eee<span class="token2">;</span>font<span class="token">-</span>weight<span class="token2">:</span>normal<span class="token2">;</span><span class="token2">}</span> <span class="token2">.</span>table tr <span class="token2">{</span>background<span class="token2">:</span>#fff<span class="token2">;</span><span class="token2">}</span> <span class="token2">.</span>table tr<span class="token2">:</span>hover <span class="token2">{</span>background<span class="token2">:</span> #d6f8dc<span class="token2">;</span><span class="token2">}</span> <span class="token2">.</span>table td a <span class="token2">{</span>color<span class="token2">:</span>#<span class="token3">06</span>f<span class="token2">;</span>text<span class="token">-</span>decoration<span class="token2">:</span>none<span class="token2">;</span><span class="token2">}</span> <span class="token2">.</span>table td a<span class="token2">:</span>hover <span class="token2">{</span>color<span class="token2">:</span>#<span class="token3">06</span>f<span class="token2">;</span>text<span class="token">-</span>decoration<span class="token2">:</span>underline<span class="token2">;</span><span class="token2">}</span> ``` ``` - 1px水平线 ``` <pre class="calibre14">``` <span class="token2">.</span>hr1 <span class="token2">{</span> width<span class="token2">:</span><span class="token3">100</span><span class="token">%</span><span class="token2">;</span> margin<span class="token2">:</span><span class="token3">0</span> auto<span class="token2">;</span> border<span class="token2">:</span> <span class="token3">0</span><span class="token2">;</span> height<span class="token2">:</span><span class="token3">0</span><span class="token2">;</span> border<span class="token">-</span>top<span class="token2">:</span> <span class="token3">1</span>px solid <span class="token1">rgba</span><span class="token2">(</span><span class="token3">0</span><span class="token2">,</span> <span class="token3">0</span><span class="token2">,</span> <span class="token3">0</span><span class="token2">,</span> <span class="token3">0.1</span><span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span> ``` ``` - 自定义选择色 ``` <pre class="calibre14">``` <span class="token2">.</span>selection<span class="token2">:</span><span class="token2">:</span>selection <span class="token2">{</span> background<span class="token2">:</span> deeppink<span class="token2">;</span> color<span class="token2">:</span> white<span class="token2">;</span> <span class="token2">}</span> ``` ``` - a属性 ``` <pre class="calibre14">``` a<span class="token2">[</span>disable<span class="token2">]</span><span class="token2">{</span> opacity<span class="token2">:</span><span class="token3">0.5</span><span class="token2">;</span> cursor<span class="token2">:</span>default<span class="token2">;</span> pointer<span class="token">-</span>events<span class="token2">:</span>none<span class="token2">}</span> ``` ``` - 横向垂直居中 ``` <pre class="calibre14">``` <span class="token2">.</span>v<span class="token">-</span>center<span class="token2">{</span> display<span class="token2">:</span>flex<span class="token2">;</span>align<span class="token">-</span>items<span class="token2">:</span> center<span class="token2">;</span>justify<span class="token">-</span>content<span class="token2">:</span>center<span class="token2">;</span> <span class="token2">}</span> ``` ``` - 必填 ``` <pre class="calibre16">``` <span class="token2">.</span>req<span class="token2">:</span>after<span class="token2">{</span> content<span class="token2">:</span> <span class="token4">' *'</span><span class="token2">;</span> color<span class="token2">:</span> #EF4F4F<span class="token2">;</span> font<span class="token">-</span>weight<span class="token2">:</span>bold<span class="token2">;</span> <span class="token2">}</span> ``` ```