簡體   English   中英

如何在css3中使高度和寬度div相同?

[英]How to make same height and width div in css3?

CSS代碼

div{
    width:50px;
    height:50px;
    background:red;
    border-radius:50px;
}
div:hover{
    width:100px;
    height:100px;
    transition:0.4s;
    -moz-transition:0.4s;
    -ms-transition:0.4s;
    -o-transition:0.4s;
    -webkit-transition:0.4s;
}

html代碼

<div>

我喜歡以相同的高度和寬度進行擴展,不僅要增加右側和底部的寬度。

除了增加widthheight您還可以使用CSS3轉換scale() div,例如

http://codepen.io/anon/pen/oXQGyO

div {
    width:50px;
    height:50px;
    background:red;
    border-radius:50px;
    -webkit-transform-origin: 0 0;
    -moz-transform-origin: 0 0;
    transform-origin: 0 0;
}

div:hover {
    -webkit-transform: scale(2);
    -moz-transform: scale(2);
    transform: scale(2);

    -webkit-transition:0.4s;
    -moz-transition:0.4s;
    transition:0.4s;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM