admin管理员组文章数量:1336632
So I wanted to make a card appear the same way its supposed to be done in the Material design spec
Short video demo
I have managed to do it using jquery on a simple red square (See first snippet) I simply give the desired element 0 height & width, and then animate the height & width with jquery to how big I want it to be.
The problem with any of the MDL cards is, I can't get the height to anything smaller than 200. You can check out my second snippet and see what happens when I try to set it to 150px.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Card</title>
<script src=".1.4/jquery.min.js"></script>
</head>
<body>
<p id="Box"></p>
<button id="Start">Start</button>
<button id="Reset">Reset</button>
<script>
$(document).ready(function() {
$("#Start").click(function(){
$('#Box').animate({height: "150px", width: "150px"},{duration: 1000});
});
$("#Reset").click(function(){
$('#Box').animate({height: "0px", width: "0px"},{duration: 1000});
});
});
</script>
<style>
#Box{
width: 0px;
height: 0px;
background-color: red;
box-shadow: -3px 1px 30px 0px rgba(50,50,50,0.25);
}
</style>
</body>
</html>
So I wanted to make a card appear the same way its supposed to be done in the Material design spec
Short video demo
I have managed to do it using jquery on a simple red square (See first snippet) I simply give the desired element 0 height & width, and then animate the height & width with jquery to how big I want it to be.
The problem with any of the MDL cards is, I can't get the height to anything smaller than 200. You can check out my second snippet and see what happens when I try to set it to 150px.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Card</title>
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<p id="Box"></p>
<button id="Start">Start</button>
<button id="Reset">Reset</button>
<script>
$(document).ready(function() {
$("#Start").click(function(){
$('#Box').animate({height: "150px", width: "150px"},{duration: 1000});
});
$("#Reset").click(function(){
$('#Box').animate({height: "0px", width: "0px"},{duration: 1000});
});
});
</script>
<style>
#Box{
width: 0px;
height: 0px;
background-color: red;
box-shadow: -3px 1px 30px 0px rgba(50,50,50,0.25);
}
</style>
</body>
</html>
$(document).ready(function(){
$('.mdl-card').animate({height: "150px", width: "0px"},{duration: 1000});
$("#Start").click(function(){
$('.mdl-card').animate({height: "150px", width: "150px"},{duration: 1000});
});
$("#Reset").click(function(){
$('.mdl-card').animate({height: "0px", width: "0px"},{duration: 1000});
});
});
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://storage.googleapis./code.getmdl.io/1.0.2/material.indigo-pink.min.css">
<script src="https://storage.googleapis./code.getmdl.io/1.0.2/material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis./icon?family=Material+Icons">
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div class="mdl-card mdl-shadow--6dp"></div>
<button id="Start">Start</button>
<button id="Reset">Reset</button>
</body>
<style>
.mdl-card{
margin: 5px 5px;
width: 0px;
height: 0px;
}</style>
</html>
Any help would be really appreciated, maybe theres a different way to do this with jquery?
Share Improve this question asked Aug 5, 2015 at 19:48 Angular DevAngular Dev 4,9162 gold badges31 silver badges39 bronze badges1 Answer
Reset to default 8After testing your code snippet and looked at everything that happens with Chromes developer console I found that .mdl-card
has a min-height
attribute in the css. Overriding that value to 0 fixed it for me.
本文标签: javascriptMDL card height customizationStack Overflow
版权声明:本文标题:javascript - MDL card height customization - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742413509a2470256.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论