display:table-cell的min-height

table-cell的元素min-height是不起作用的,直接使用height就行,当高度不足时,table会自动拉伸cell元素。

此时,height相当于min-height。

 

出处:https://stackoverflow.com/questions/7790222/css-display-table-min-height-not-working

转载于:https://www.cnblogs.com/mengff/p/8359136.html

用jquery精简一下程序<!DOCTYPE html> <html lang="en"> <head> <title>Styles Example</title> <style type="text/css"> .myDiv { background-color: blue; width: 150px; height: 150px; margin-right: 20px; display: table-cell; vertical-align: middle; text-align: center } .highlight { font-size: xx-large; } span { display: block; color: yellow; text-align: center; } </style> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script> </head> <body> <table> <tr> <td> <div class="myDiv highlight"> <span>虎虎生威</span> </div> </td> <td> <div class="myDiv"> <span>生龙活虎</span> </div> </td> </tr> <tr> <td> <div class="myDiv"> <span>如虎添翼</span> </div> </td> <td> <div class="myDiv"> <span>卧虎藏龙</span> </div> </td> </table> <button onclick="start()" id="start">开始</button> <button onclick="stop()" disabled="disabled" id="stop">停止</button> <button onclick="resume()" disabled="disabled" id="resume">继续</button> <script> let divs = $(".myDiv"); //取得所有div let startBtn = $("#start"); //取得开始按钮 let stopBtn = $("#stop"); //取得停止按钮 let resumeBtn = $("#resume"); //取得继续按钮 let nums = [0, 1, 3, 2]; let index = 0, timerId; function start() { startBtn.prop("disabled", true); for (let num of nums) { divs.eq(nums[index]).removeClass("highlight"); } index = 0; divs.eq(nums[0]).addClass("highlight"); resume(); } function stop() { clearInterval(timerId); stopBtn.prop("disabled", true); startBtn.removeAttr("disabled"); resumeBtn.removeAttr("disabled"); } function resume() { resumeBtn.prop("disabled", true); stopBtn.removeAttr("disabled"); timerId = window.setInterval(function () { divs.eq(nums[index]).removeClass("highlight"); index = (index + 1) % 4; divs.eq(nums[index]).addClass("highlight"); }, 500); } </script> </body> </html>
最新发布
05-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值