如何在图像控件中显示图像的原始大小

时间:2018-06-05 17:43:36

标签: c# css asp.net

enter image description here我尝试将CS​​S高度设置为自动,然而,图像没有显示,所以我不得不放一个固定的高度。我尝试调整大小模式,它也没有用。我尝试添加“img-responsive”,但它也没有用。

CSS

.imgFile {
 width: 100%;
 max-width: 100%;
 height: 100px;
 max-height:100%;
 margin-left: 7px;
 margin-right: 0px;
 margin-top: 5px;
 margin-bottom: 1px;
 background-repeat: no-repeat;
 background-color: white;
 background-size: 100%, 100%;
}

Asp.net

   System.Web.UI.WebControls.Image image = new 
    System.Web.UI.WebControls.Image();
        image.ID = file.Name + file.Oid;
        image.Attributes.Add("class", "imgFile");
        image.Attributes.Add("class", "img-responsive");
        image.Style.Add("background-image", "'LogoHeaderHandler.axd?f=" 
    + file.Oid + "&" + DateTime.Now.ToFileTime() + "'");

1 个答案:

答案 0 :(得分:1)

看起来你有2个问题。

1)Attributes.Add根据您当前的代码清除您的imgFile类。如果您需要两者,则必须将它们一起添加到一行中,如下所示:

with tf.Session() as sess:  
    saver = tf.train.import_meta_graph('path to .meta')  
    saver.restore(sess, tf.train.latest_checkpoint('path to checkpoints'))  
    result = (sess.run(tf.argmax(prediction.eval(feed_dict=x:input_data}),1)))  
    print(result)  

2)您的CSS具有以下内容:background-size:100%,100%;需要将其删除以保留图像的“原始”尺寸,否则会拉伸图像。

你所拥有的其他代码似乎给了我你想要的结果(*授予你的处理程序按预期工作......我没有在我的测试中模拟这部分。)

相关问题