SVG高度不随宽高比调整

时间:2017-04-10 08:47:33

标签: html css svg

在div中使用了一个svg图像,宽度为50px,但在IE11中,SVG高度为150px。应该是50px X 50px。宽度50px正确应用而不是高度。任何建议,



@Override
protected ArrayList<String> doInBackground(String... params) {
    String tableName = params[0];

    ArrayList<String> tempList = new ArrayList<String>();

    AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient (
            new BasicAWSCredentials(Constants.ACCESS_KEY_ID,
                    Constants.SECRET_KEY));

    ScanRequest scanRequest = new ScanRequest()
        .withTableName(tableName);
        //.withAttributesToGet("name");
    com.amazonaws.services.dynamodb.model.ScanResult result = dynamoDBClient.scan(scanRequest);


    for (Map<String, AttributeValue> item : result.getItems()) {
        tempList.add(item.toString());
        //analizeItem(tempList, item);
    }

    return tempList;
}
&#13;
.svg-cont{
  width:50px
}
img{
  max-width:100%;
  height:auto;
}
&#13;
&#13;
&#13;

提前感谢您的帮助。 codepen:http://codepen.io/shmdhussain/pen/YZmrOq

1 个答案:

答案 0 :(得分:0)

感谢问题在将宽度:100%设置为图像标记后解决。问题解决了笔码:http://codepen.io/shmdhussain/pen/XMvzWv

&#13;
&#13;
.svg-cont{
  width:50px
}
img{
  max-width:100%;
  width:100%;
  height:auto;
}
&#13;
<div class="svg-cont">
  <img src="http://imgh.us/google-plus-hvr.svg" alt="" />
</div>
&#13;
&#13;
&#13;

参考:https://tympanus.net/codrops/2014/08/19/making-svgs-responsive-with-css/