分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

几个实用的CSS代码段总结

发布时间:2023-09-06 02:25责任编辑:赖小花关键词:CSS

  废话不多说,直接上代码,希望能帮到有需要的小伙伴

  ①:遮罩

  

   position: fixed; ???background: rgba(0, 0, 0, .4); ???top: 0; ???left: 0; ???right: 0; ???bottom: 0; ???z-index: 99; ???width: 100%; ???height: 100%;

  

  ②:三角(下面三角的代码按照下图上右下左的顺序排列)

  

   width: 0; ???height: 0; ???border-width: 8px; ???border-style: solid; ???border-color: transparent transparent #000 transparent;
  width: 0; ??height: 0; ??border-width: 8px; ??border-style: solid; ??border-color: #000 transparent transparent transparent;
  width: 0; ??height: 0; ??border-width: 8px; ??border-style: solid; ??border-color: transparent #000 transparent transparent;
  width: 0; ??height: 0; ??border-width: 8px; ??border-style: solid; ??border-color: transparent #000 transparent transparent;

  ③:圆

  

 ??display: inline-block; ??width: 10px; ??height: 10px; ??border-radius: 50%; ??background-color: #f6ad03;

  ④:图标

  

  width: 24px; ??box-shadow: 0 10px 0 2px #999, 0 20px 0 2px #999, 0 30px 0 2px #999;

  

  ⑤:超出隐藏

  

  width: 180px;  overflow: hidden;  text-overflow: ellipsis;  white-space: nowrap;

  6:垂直居中

  position: fixed; ??top: 0; ??right: 0; ??bottom: 0; ??left: 0; ??margin: auto;

  注:针对元素有固定宽高的情况

  

   position: fixed; ???top: 50%; ???left: 50%; ???z-index: 999; ???transform: translate(-50%,-50%);

  注:针对元素无固定宽高的情况

  

  

 

  

  

几个实用的CSS代码段总结

原文地址:https://www.cnblogs.com/tu-0718/p/10065896.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved