css《垂直居中_定高度不定高度》方式

news/2024/5/19 18:43:40 标签: center, transform, flex, position

垂直居中

文章目录

    • 垂直居中
      • 有高度
      • 没有高度

有高度

  • 方式一:(height)使用 margin + position
  • 方式二:(height) 使用 margin
/*方式一:*/
.center {
   height: 100px;
   width: 200px;
   position: absolute;
   top: 50%;
   margin-top: -50px;
   background-color: yellow;
}
/*方式二:*/
.center {
     height: 100px;
     margin: 50px 0;
     background-color: red;
 }

没有高度

/*方式一:*/
.center {
	  position: absolute;
	  top: 50%;
	  transform: translateY(-50%);
	  background-color: yellow;
}
/*方式二:*/
.wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}
.center {
    width: 100%;
    background-color: rebeccapurple;
}

http://www.niftyadmin.cn/n/1581819.html

相关文章

css《水平居中》

水平居中 方式一&#xff1a;使用 行内元素方式二&#xff1a;使用 margin方式三&#xff1a;使用 position方式四&#xff1a;使用 伪元素 <div class"wrap"><div class"center">Test</div> </div> /*方式一&#xff1a;*/ .w…

v-model双向绑定获取单选按钮值《计算评分》

项目需求&#xff1a; 根据选题测评用户体质类别 有九类体质&#xff0c;每一类有&#xff08;7&#xff0c;8&#xff09;道选择题每一道选择题答案有5个&#xff0c;对应分数&#xff08;1分&#xff0c;2分&#xff0c;3分&#xff0c;4分&#xff0c;5分&#xff09;最后…

echarts多种图形使用

echarts 图形使用分享&#xff0c;写得不好&#xff0c;请各位大神多多指教… 饼图 pie折线图 line柱形图 bar 文章目录效果图1&#xff1a;效果图2&#xff1a;参数说明及数据格式饼图封装方法折线图封装方法柱状图封装方法使用指南1. 静态html2. 初始化echarts 获取Dom元素3.…

echarts x轴 增加滚动条 dataZoom

文章目录echarts x轴 增加滚动条dataZoom配置效果图echarts x轴 增加滚动条 在option 配置项中添加 【 dataZoom 中配置 】 设置x轴滚动条效果图&#xff1a; 动态拖动以下参考代码 dataZoom配置 option {xAxis: {type: category,data: [Mon, Tue, Wed, Thu, Fri, Sat, Sun…

echarts 关于axisLabel文字换行显示

文章目录echarts 关于axisLabel文字换行显示方式一&#xff1a;js实现echarts 关于axisLabel文字换行显示 axisLabel文字换行》两种方式方式一&#xff1a; 动态方式二&#xff1a; js代码&#xff1a; 写在var option{};之后&#xff0c;在myChart.setOption(option);之前本文…

easyui tree去掉文件夹icon图标

文章目录easyui tree去掉文件夹节点图标效果图js代码htmleasyui tree去掉文件夹节点图标 效果图js代码html代码 效果图 js代码 /******************去掉 tree树 文件夹图标*************************/ $(function () {// 找到 #treeBox 树形 id&#xff0c; 再移除图标$(#tr…

easyui datebox不能大于当前时间

easyui datebox日期控件不能大于当前时间 最近使用easyui中DataGrid数据表格&#xff0c; 其中应用了datebox日期控件 1.添加datebox必填项属性&#xff1a; required:true2.datebox时间框禁用编辑&#xff1a; editable:false3.判断选择时间不能大于当前时间 DataGrid 添加…

一个页面有多个datagrid如何封装复用?

文章目录一个页面有多个DataGrid如何复用&#xff1f;介绍指南项目需求&#xff1a;效果图1&#xff1a;没有数据效果图2: 有数据1. 封装DataGrid2. 结合radio禁用启用 DataGrid 删除&添加按钮3. vue 遍历 "无"数据 状态 控制 DataGrid - 按钮4. html一个页面有…