首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在下载图像之前,在webview中设置图像的背景色

在下载图像之前,在webview中设置图像的背景色
EN

Stack Overflow用户
提问于 2017-06-20 11:41:14
回答 1查看 365关注 0票数 1

如何在下载图像时,在webview中设置图像的默认背景色。在我当前的情况下,我用于图像的css是

代码语言:javascript
复制
img {
  display : block;
  box-sizing:border-box;
  background:#eeeeee;
  margin : auto;
  margin-top : 24pt;
  margin-bottom : 24pt;
  width: inherit;
  height: inherit;
}

但是在这种情况下,我的webview UI在图像下载之前没有显示任何空间或背景,一旦下载了图像,我的UI就会拉伸,为图像腾出空间,然后呈现图像背景和图像。

如何在下载和呈现图像之前为图像标记分配空间和设置背景。

就像这个html

代码语言:javascript
复制
<!DOCTYPE html>
<html>
  <head>
     <meta charset='UTF-8' /><meta name='viewport' content='width=device-width, initial-scale=1'>
     <link rel="stylesheet" href="roboto.css"><link rel="stylesheet" href="webview.css">
  </head>
  <body>
     <p>According to a recent tweet from noted tipster Evan Blass (@evleaks) the upcoming Samsung Galaxy Note 8 is internally codenamed "Samsung Gr3at". The number 3 apparently signifies three new features that are coming to the Note 8.
     </p>
     <img class="alignnone size-full wp-image-3061" src="https://app.abc.com/wp-content/uploads/2017/06/evleaks-Note-8.jpg" alt="" width="640" height="300" />
     <p>Although everything about the upcoming phablet is mere speculation, it is believed that the Note 8 will feature the new Infinity Display, a Snapdragon 836 SoC and a dual camera setup. Samsung is expected to launch the Galaxy Note 8 in August.
     </p>
  </body>
</html>

所有段落都会立即加载,但在获取图像之前和获取图像时,都不会留下任何图像空间,然后ui就会拉伸以显示图像。如何在下载前根据img标签大小来设置图像的空间。

基本上我想知道如何在html.中为图像标记设置占位符。

EN

回答 1

Stack Overflow用户

发布于 2017-06-20 12:47:11

你能试试吗:

CSS:

代码语言:javascript
复制
.myDiv {

  border: 2px gray;
  display : block;
  box-sizing:border-box;
  background:red;
  margin : auto;
  margin-top : 24pt;
  margin-bottom : 24pt;
  width: 100%;
  height: inherit;
}

HTML:

代码语言:javascript
复制
 <body>
     <p>According to a recent tweet from noted tipster Evan Blass (@evleaks) the upcoming Samsung Galaxy Note 8 is internally codenamed "Samsung Gr3at". The number 3 apparently signifies three new features that are coming to the Note 8.
     </p>
     <div class='myDiv'>
        <img class="alignnone size-full wp-image-3061" src="http://www.jqueryscdript.net/images/Simplest-Responsive-jQuery-Image-Lightbox-Plugin-simple-lightbox.jpg" alt="" width="640" height="300" />
     </div>

     <p>Although everything about the upcoming phablet is mere speculation, it is believed that the Note 8 will feature the new Infinity Display, a Snapdragon 836 SoC and a dual camera setup. Samsung is expected to launch the Galaxy Note 8 in August.
     </p>
  </body>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44652091

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档