svg圖片自適應div容器大小

http://thenewcode.com/744/Make-SVG-Responsivecss

<!DOCTYPE html>
<html>
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
        <title>監控視圖</title>
        <style type="text/css">
.svg-container { 
    display: inline-block;
    position: relative;
    width: 100%;
    padding-bottom: 100%; 
    vertical-align: middle; 
    overflow: hidden; 
}
        </style>
    </head>
    <body>
        <div class="svg-container">
            <svg version="1.1" viewBox="0 0 500 500" preserveAspectRatio="xMinYMin meet" class="svg-content">
            <circle fill="#F7941E" stroke="#231F20" stroke-width="10" stroke-miterlimit="10" cx="250" cy="250" r="200" opacity="0.6" />
            </svg>
        </div>
    </body>
</html>

  能夠嘗試去改變svg-container的width屬性,裏面的圖片會自適應哦!具體原理在慢慢探究吧html

相關文章
相關標籤/搜索