html - 我可以将高度方向从自上而下反转为自下而上吗?

标签 html css height direction

我想将高度增长路径从自上而下改为自下而上。在 CSS 中可能吗?

.button {
    margin-top:200px;
    margin-right:34px;
    width:150px;
    height:45px;
    background:black;
    float:right;
    transition-duration:2s;  
}
.buttom:hover{
    height:180px;
    transition-duration:2s;
}
<div class='button'> </div>

http://jsfiddle.net/yasharshahmiri/1pkemq1p/3/

最佳答案

您只需像这样设置 position: absolutebottom 位置:

.buttom{
    margin-top:200px;
    margin-right:34px;
    width:150px;
    height:45px;
    background:black;
    float:right;
    position:absolute;
    bottom: 10px;
    transition: height 2s ease-in-out  
}
.buttom:hover{
    height:180px
}
                       <div class='buttom'> </div>

使用Rotatetransform-origin能够设置相对于元素的位置

.buttom{
    margin-top:200px; /* this shall be higher than the height on hover*/
    margin-right:34px;
    width:150px;
    height:45px;
    background:black;
    transition: height 2s ease-in-out ;
    transform: rotatex(180deg);
    transform-origin: top;
}
.buttom:hover{
    height:180px
}
                       
<div class='buttom'> </div>

或者这样:

.buttom{
    width:150px;
    height:45px;
    background:black;
    transition: height .3s cubic-bezier(0.175, 0.885, 0.32, 1.275) ;
    transform: rotatex(180deg) translate3d(0, -200px,0);/* the Y-Value shall be higher than the height on hover*/
    transform-origin: top;
}
.buttom:hover{
    height:180px
}
    
<div class='buttom'></div>

关于html - 我可以将高度方向从自上而下反转为自下而上吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27451132/

相关文章:

CSS 文本消失

javascript - 使用 animate 中的 Step 函数来变换旋转元素

javascript - SlidesJS 将 Slidesjs-container 的高度设置为幻灯片的高度?

html - 表格 tr 高度固定不适用于 Chrome

html - 如何应用具有透明到白色渐变的淡出文本效果?

javascript - 更改嵌套 html 元素的颜色后,悬停效果将不起作用

javascript - 使用 html 从变量中删除样式标签

css - JQuery UI 默认 CSS 值以提供一致的大小

css - 无法正确调整导航至 100% 的高度

html - 总是自动关闭 html 中的空标签有什么问题吗?