我有以下代码:
public static Dictionary<string, string[]> dict = new Dictionary<string, string[]>() {
"key1", { "value", "another value", "and another" }
};
Run Code Online (Sandbox Code Playgroud)
这是不正确的。错误列表包含以下内容:
方法“Add”没有重载需要 3 个参数
没有给出对应于 'Dictionary.Add(string, string[])' 的所需形式参数 'value' 的参数
我基本上只想用预设值初始化我的字典。不幸的是,我不能使用代码方式初始化,因为我在一个静态类中工作,其中只有变量。
我已经尝试过这些事情:
... {"key1", new string[] {"value", "another value", "and another"}};... {"key", (string[]) {"value", "another value", "and another"}};但我没有运气。任何帮助表示赞赏。
PS:如果我使用两个参数,日志会显示can't convert from string to string[].
我使用以下HTML结构:
<div class="imgview_overlay" id="imageviewer">
<div class="overlay_content">
<div class="overlay_inner" id="overlay_img_div">
<img id="overlay_img" alt="overlayed_image" style="visibility: hidden;" />
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用以下CSS:
.imgview_overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,.2); visibility: hidden; z-index: 500; }
.overlay_content { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; overflow: auto; }
.overlay_inner { display: inline-block; }
Run Code Online (Sandbox Code Playgroud)
将<img>标签水平和垂直居中放置在叠加层内.
在overflow: auto;它的工作,但不正确.图像的顶部(当页面缩小时)不会出现.举个例子,看看这个小提琴.关于如何解决这个问题的任何想法?