冷血

文章 评论 浏览 27

冷血 2025-02-17 22:38:01

将每次复制您的价值复制,以及std ::向量preallaist cose as Bunch of Bunch。复制时间更大

sort copy your values every time and std::vector preallocate a bunch of memory. The amount of copy time is bigger

std ::矢量使结构排序缓慢? C++

冷血 2025-02-17 21:06:29

分配变量时,您不使用echo

$name = isset($_GET['name']) ? $_GET['name'] : 'anonymous';
echo $name;

在现代php中,您可以使用零煤的操作员:

$name = $_GET['name'] ?? 'anonymous';
echo $name;

You don't use echo when you're assigning a variable.

$name = isset($_GET['name']) ? $_GET['name'] : 'anonymous';
echo $name;

In modern PHP you can use the null-coalescing operator:

$name = $_GET['name'] ?? 'anonymous';
echo $name;

检查Isset和Echo''在屏幕上

冷血 2025-02-17 17:56:53

您可以触摸标记吗?并添加一个线路(在您希望线路断路的任何弹性项目之后)。添加< div class =“ line-break”></div>在您想要链接中断的项目之后,此css .line-break {width {width:100%;可见性:隐藏;}flex-flow:row wrap; to .products

.Home {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: stretch;
  align-content: stretch;
}

.Products {
  display: flex !important;
  flex-direction: row !important;
  width: 100% !important;
  height: 100px;
  color: white;
  flex-flow: row wrap;
}

.Item {
  margin-right: 3%;
  /* start: added by editor for visualization purpose */
  min-height: 75px;
  border: 2px dashed red;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: gray;
  /* end: added by editor for visualization purpose */
}

.line-break {
  width: 100%;
  visibility: hidden;
}
<div class="Home">
  <section class="Products">
    <div class="Item">1</div>
    <div class="Item">2</div>
    <div class="Item">3</div>
    <div class="Item">4</div>
    <div class="line-break"></div>
    <div class="Item">5</div>
    <div class="Item">6</div>
    <div class="Item">7</div>
    <div class="Item">8</div>
  </section>
  <div>
    <button>Add Product</button>
  </div>
</div>

或使用网格,它总是可以进行这种布局。

.Item {
  width: 100px;
  height: 100px;
  margin: 0.5rem;
  border: 1px solid #000000;
  text-align: center;
}

.Products {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
<div class="Home">
  <section class="Products">
    <div class="Item">1</div>
    <div class="Item">2</div>
    <div class="Item">3</div>
    <div class="Item">4</div>
    <div class="Item">5</div>
    <div class="Item">6</div>
    <div class="Item">7</div>
    <div class="Item">8</div>
  </section>
  <div>
    <button>Add Product</button>
  </div>
</div>

Can you touch the markup? And add a line break (after whatever flex item you want the line to break). Add <div class="line-break"></div> after the item you want link break, this css .line-break {width: 100%; visibility: hidden;} and a flex-flow: row wrap; to .Products

.Home {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: stretch;
  align-content: stretch;
}

.Products {
  display: flex !important;
  flex-direction: row !important;
  width: 100% !important;
  height: 100px;
  color: white;
  flex-flow: row wrap;
}

.Item {
  margin-right: 3%;
  /* start: added by editor for visualization purpose */
  min-height: 75px;
  border: 2px dashed red;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: gray;
  /* end: added by editor for visualization purpose */
}

.line-break {
  width: 100%;
  visibility: hidden;
}
<div class="Home">
  <section class="Products">
    <div class="Item">1</div>
    <div class="Item">2</div>
    <div class="Item">3</div>
    <div class="Item">4</div>
    <div class="line-break"></div>
    <div class="Item">5</div>
    <div class="Item">6</div>
    <div class="Item">7</div>
    <div class="Item">8</div>
  </section>
  <div>
    <button>Add Product</button>
  </div>
</div>

Or use grid which is always a go to approach for such kind of layouts.

.Item {
  width: 100px;
  height: 100px;
  margin: 0.5rem;
  border: 1px solid #000000;
  text-align: center;
}

.Products {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
<div class="Home">
  <section class="Products">
    <div class="Item">1</div>
    <div class="Item">2</div>
    <div class="Item">3</div>
    <div class="Item">4</div>
    <div class="Item">5</div>
    <div class="Item">6</div>
    <div class="Item">7</div>
    <div class="Item">8</div>
  </section>
  <div>
    <button>Add Product</button>
  </div>
</div>

在flexbox中的儿童中显示儿童中的项目

冷血 2025-02-17 07:35:16

您可以首先将JSON字符串验证为这样的对象:

public class TheThing
{
    public string parameterName1 { get; set; }
    public string parameterName2 { get; set; }
    public Parametername3[] parameterName3 { get; set; }
}

public class Parametername3
{
    public string parameterName3Key { get; set; }
    public string parameterName3Value { get; set; }
}

然后使用.todictionary

var path = @"C:\dBConfig.json";
var jsonString = File.ReadAllText(path);
var theThing = JsonConvert.DeserializeObject<TheThing>(jsonString);
var outputDict = theThing.parameterName3.ToDictionary(x => x.parameterName3Key);

You can first deserialize your JSON string into an object like this:

public class TheThing
{
    public string parameterName1 { get; set; }
    public string parameterName2 { get; set; }
    public Parametername3[] parameterName3 { get; set; }
}

public class Parametername3
{
    public string parameterName3Key { get; set; }
    public string parameterName3Value { get; set; }
}

and then use .ToDictionary:

var path = @"C:\dBConfig.json";
var jsonString = File.ReadAllText(path);
var theThing = JsonConvert.DeserializeObject<TheThing>(jsonString);
var outputDict = theThing.parameterName3.ToDictionary(x => x.parameterName3Key);

需要帮助使用C#存储从JSON到字典的特定值的帮助

冷血 2025-02-16 19:52:14

您的代码和问题都没有意义。

您的label()函数中的打印语句甚至不应编译:

print(subTitle.text = (name))

该怎么办?打印语句将将输出记录到调试控制台。但是,express subtitle.text =(name)看起来不像合法的swift。您是否试图判断标签字段的内容是否包含数组中的一个字符串?如果是这样,您需要使用==(比较)不是=(分配。)

尝试:

print("label text = \(name) ==", subTitle.text == (name))

Neither your code nor your question make much sense.

The print statement in your label() function should not even compile:

print(subTitle.text = (name))

What is that supposed to do? The print statement will log output to the debug console. however, the expression subTitle.text = (name) does not look like legal swift. Are you trying to tell if the contents of your label field contains one of the strings in your array? If so, you need to use == (comparison) not = (assignment.)

Try:

print("label text = \(name) ==", subTitle.text == (name))

我想在迅速循环,但我有问题

冷血 2025-02-16 05:50:12

查看文档,我可以看到每个子查询都在括号中,例如:

select *从(从“测量”中选择“值”)&lt; where_caluse&gt;

因此,对括号的beetwen“来自”和“在哪里”应该足够。

基于:

#1 https> https:htttps:// www。 InfruxData.com/blog/tldr-influxdb-tech-tips-january-26-2017/

#2 https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#subqueries

Looking into docs, articles I can see that every subquery is in brackets, like:

select * from (select "value" from "measurement") <where_caluse>

So filtering for brackets beetwen "FROM" and "WHERE" should be enough.

Based on:

#1 https://www.influxdata.com/blog/tldr-influxdb-tech-tips-january-26-2017/

#2 https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#subqueries

如何防止用户提供的测量中的SQL注入SQL注入

冷血 2025-02-16 01:53:40

官方的文档说的.map是

将此流的每个元素转换为一个新的流事件。

因此,您必须聆听“流”的“ AA”变量才能开始侦听数据。喜欢:

aa.listen(
  (event) => print("Data Retrieved"),
);

What offical document says .map is

Transforms each element of this stream into a new stream event.

So you have to listen "aa" variable which is "Stream" to start listening data. like:

aa.listen(
  (event) => print("Data Retrieved"),
);

颤音:firebase查询课程,它在地图中没有示意打印功能

冷血 2025-02-16 01:40:51

您可以将Insert_after复制组合使用:

import copy

origin_tag.insert_after(copy.copy(origin_tag))

这使其成为原始标签的副本,并在Origin标签之后插入它。

You can use insert_after in combination with copy:

import copy

origin_tag.insert_after(copy.copy(origin_tag))

This makes a copy of origin tag and inserts it after origin tag.

重复一个标签后,我该如何复制标签插入?

冷血 2025-02-15 20:29:32

您无法在对象上使用地图,因此应该将其转换为:

<div>
  {Object.keys(nfts).map((nft, index) => (
    <NFTCard nft={nft} key={index} />
  ))}
</div>

You can not use map on object so you should convert it :

<div>
  {Object.keys(nfts).map((nft, index) => (
    <NFTCard nft={nft} key={index} />
  ))}
</div>

.map不是功能反应,轴问题

冷血 2025-02-15 16:13:44

如果您唯一对括号的使用是用于标签,则可以只使用

$text = 'This is (foo)((bar))';

$text = strtr($text, array('(' => '<del>', ')' => '</del>', '((' => '<ins>', '))' => '</ins>'));
echo $text;

output:

This is <del>foo</del><ins>bar</ins>

strtr在这种情况下起作用,因为它首先替换了数组中的较长字符串,因此任何((...))都将在将字符串解析为(...)替换为del> del标签之前,用ins标签替换。

否则,您将需要检查开口不在之前或之后是其他)( 替换为del标签),您可以执行此操作。带有负面的镜头:

$text = preg_replace('/(?<!\()\((?!\()([^)]*)\)/', '<del>$1</del>', $text);
$text = preg_replace('/\(\(([^)]*)\)\)/', '<ins>$1</ins>', $text);
echo $text;

输出:

This is <del>foo</del><ins>bar</ins>

on 3v4l.org上的demo

请注意,请注意,使用[^)]*\)。*?\)更有效“>对比。

If your only use of parentheses is for tags, you could just use strtr:

$text = 'This is (foo)((bar))';

$text = strtr($text, array('(' => '<del>', ')' => '</del>', '((' => '<ins>', '))' => '</ins>'));
echo $text;

Output:

This is <del>foo</del><ins>bar</ins>

strtr works in this situation because it replaces the longer strings in the array first so any ((...)) will be replaced with ins tags before the string is parsed for (...) to replace with del tags.

Otherwise, you will need to check that the opening ( is not preceded or followed by another ( when replacing with del tags, which you can do with negative lookarounds:

$text = preg_replace('/(?<!\()\((?!\()([^)]*)\)/', '<del>$1</del>', $text);
$text = preg_replace('/\(\(([^)]*)\)\)/', '<ins>$1</ins>', $text);
echo $text;

Output:

This is <del>foo</del><ins>bar</ins>

Demo on 3v4l.org

Note that using [^)]*\) is more efficient than .*?\) due to contrast.

preg_replace()捕获第一场比赛

冷血 2025-02-15 14:57:56

您的JSON包含2个属性 - XMLuser_details(不知道为什么在调试窗口中有user_logon,也许可能未显示某些设置)。

因此,您可以访问Eg first_name

var firstName = resultJson2.USER_DETAILS.USER.USR_FIRST_NAME; // or USER_LOGON instead of USER_DETAILS

Your JSON contains 2 properties - xml and USER_DETAILS (don't know why you have USER_LOGON in debug window, maybe some settings not shown in question).

So you can access e.g. FIRST_NAME:

var firstName = resultJson2.USER_DETAILS.USER.USR_FIRST_NAME; // or USER_LOGON instead of USER_DETAILS

应对包含XML声明的JSON进行审理

冷血 2025-02-15 14:46:09

从客户的角度来看,似乎在您renderui另一个元素之前,该文档已充分加载。因此,jQuery $(文档).Dready(...)可以继续尝试将事件附加到尚不存在的元素。

避免renderui的选项已得到给出。如果您不希望“占位符”空白空间,则可以在渲染时将图像高度设置为零:

ui <- fluidPage(
## ...
    imageOutput("img", click = "photo_click",
    height = 0
    )
## ...

Seems like, from the client's perspective, the document is fully loaded before you renderUI another element. So the JQuery $(document).ready(...) gives its OK to proceed with trying to attach an event to an element which is not there (yet).

Options to avoid renderUI have already been given. If you don't want the "placeholder" blank space, you can set the image height to zero upon rendering:

ui <- fluidPage(
## ...
    imageOutput("img", click = "photo_click",
    height = 0
    )
## ...

在Shiny应用中使用`renderui'时附加JavaScript侦听器

冷血 2025-02-15 14:16:38

如果缺少任何所需的配置,则可以包括一个单位测试,该单元测试会失败。

假设您正在运行单元测试作为构建管道的一部分,则如果测试失败,则应阻止部署。

这个问题可能会帮助您实现这一目标。

You could include a Unit Test that fails if any of your required configurations are missing.

Assuming you're running the Unit Tests as part of the build pipeline, if the test fails it should prevent deployment.

This question might help you achieve this.

验证AppSettings.json作为CI/CD管道的一部分

冷血 2025-02-15 03:57:28

调用reset_index()(以及add_suffix()

通常,reset_index()在您调用pivot_table之后,需要或Pivot。例如,要进行以下转换(其中一个列成为列名)

< img src =“ https://i.sstatic.net/slcqf.png” alt =“ res”>

您使用以下代码,在pivot之后,您可以在新创建的列名称并将索引转换为(在这种情况下为“电影”)回到列中,然后删除轴名称的名称:

df.pivot(index='movie', columns='week', values='sales').add_prefix('week_').reset_index().rename_axis(columns=None)

如提到的其他答案,“枢轴”可能是指2个不同的操作:

  1. 的结果。
  2. 未堆放的聚合(即制作groupby.agg更宽 在r)

1中。聚合

pivot_tablecrosstab只是groupby.agg操作的未堆放结果。实际上,

  • pivot_table = groupby + unstack在此处阅读以获取更多信息。)
  • crosstab = pivot_table

nb您可以将列名称列表用作index,<代码>列和values参数。

df.groupby(rows+cols)[vals].agg(aggfuncs).unstack(cols)
# equivalently,
df.pivot_table(vals, rows, cols, aggfuncs)
1.1。 crosstabpivot_table的特例;因此,groupby + unstack

以下是等效的:

  • pd.crosstab(df ['cola'],df ['colb'])
  • <代码> df.pivot_table(index ='cola',列='colb',aggfunc ='size',fill_value = 0)
  • df.groupby(['cola','colb'])。 size()。unstack(fill_value = 0)

请注意,pd.crosstab的开销明显更大,因此比这两个pivot_table都明显慢得多。 groupby + <代码> unstack 。实际上,AS 在这里注明pivot_tablegroup> group + unstack

2。重塑

pivotpivot_table的更有限的版本,其中其目的是将长数据框架重塑为长期。

df.set_index(rows+cols)[vals].unstack(cols)
# equivalently, 
df.pivot(index=rows, columns=cols, values=vals)
2.1。增强行/列作为问题10中,

您还可以将问题10的见解应用于多列枢轴操作。有两种情况:

  • “远到长” :通过增加指数

    来重塑

    “

    代码:

      df = pd.dataframe({'a':[1,1,1,1,2,2,2,2],'b':[*'xxyyzz' ],, 
                       'c':[*'ccdcdd'],'e':[100,200,300,400,500,600]})
    行,cols,vals = ['a','b'],['c'],'e'
    
    #使用枢轴语法
    df1 =((
        df.Assign(ix = df.groupby(行+cols).cumcount())
        。
        。
        。
    )
    
    #等效地,使用set_index + unstack语法
    df1 =((
        DF
        .set_index([ *rows,df.groupby(rows+cols).cumcount(), *cols])[vals])[vals]
        .unstack(fill_value = 0)
        。
    )
     
  • “ toff to with wide” :通过增强列来重塑列

    “

    代码:

      df1 =(
        df.Assign(ix = df.groupby(行+cols).cumcount())
        。
        。
    )
    df1 = df1.set_axis([f“ {c [0]} _ {c [1]}” df1中的C,axis = 1).Reset_index()
    
    #等效地,使用set_index + unstack语法
    df1 =((
        DF
        .set_index([ *rows,df.groupby(rows+cols).cumcount(), *cols])[vals])[vals]
        。
    )
    df1 = df1.set_axis([f“ {c [0]} _ {c [1]}” df1中的C,axis = 1).Reset_index()
     
  • 使用set_index + unstack最小情况>语法:

    “

    代码:

      df1 = df.set_index(['a',df.groupby('a') = 0).add_prefix('col')。reset_index()
     

1 pivot_table()值并解开它。具体来说,它使用传递的聚合方法创建了索引和列的单个平面列表,将其作为groupby()使用此列表,并使用传递的聚合方法(默认值为 earge> eargegator >) )。然后,在汇总之后,它通过列列表调用unstack()。因此,在内部, pivot_table = groupby + unstack 。此外,如果传递了fill_value,则调用fillna()

换句话说,产生pv_1的方法与以下示例中产生gb_1的方法相同。

pv_1 = df.pivot_table(index=rows, columns=cols, values=vals, aggfunc=aggfuncs, fill_value=0)
# internal operation of `pivot_table()`
gb_1 = df.groupby(rows+cols)[vals].agg(aggfuncs).unstack(cols).fillna(0, downcast="infer")
pv_1.equals(gb_1) # True

2 crosstab()调用pivot_table(),即, crosstab = pivot_table 。具体来说,它从传递的值阵列中构建一个数据框,通过通用索引和调用pivot_table()对其进行过滤。它比pivot_table()更有限制列作为value

Call reset_index() (along with add_suffix())

Oftentimes, reset_index() is needed after you call pivot_table or pivot. For example, to make the following transformation (where one column become column names)

res

you use the following code, where after pivot, you add prefix to the newly created column names and convert the index (in this case "movies") back into a column and remove the name of the axis name:

df.pivot(index='movie', columns='week', values='sales').add_prefix('week_').reset_index().rename_axis(columns=None)

As the other answers mentioned, "pivot" may refer to 2 different operations:

  1. Unstacked aggregation (i.e. make the results of groupby.agg wider.)
  2. Reshaping (similar to pivot in Excel, reshape in numpy or pivot_wider in R)

1. Aggregation

pivot_table or crosstab are simply unstacked results of groupby.agg operation. In fact, the source code shows that, under the hood, the following are true:

  • pivot_table = groupby + unstack (read here for more info.)
  • crosstab = pivot_table

N.B. You can use list of column names as index, columns and values arguments.

df.groupby(rows+cols)[vals].agg(aggfuncs).unstack(cols)
# equivalently,
df.pivot_table(vals, rows, cols, aggfuncs)
1.1. crosstab is a special case of pivot_table; thus of groupby + unstack

The following are equivalent:

  • pd.crosstab(df['colA'], df['colB'])
  • df.pivot_table(index='colA', columns='colB', aggfunc='size', fill_value=0)
  • df.groupby(['colA', 'colB']).size().unstack(fill_value=0)

Note that pd.crosstab has a significantly larger overhead, so it's significantly slower than both pivot_table and groupby + unstack. In fact, as noted here, pivot_table is slower than groupby + unstack as well.

2. Reshaping

pivot is a more limited version of pivot_table where its purpose is to reshape a long dataframe into a long one.

df.set_index(rows+cols)[vals].unstack(cols)
# equivalently, 
df.pivot(index=rows, columns=cols, values=vals)
2.1. Augment rows/columns as in Question 10

You can also apply the insight from Question 10 to multi-column pivot operation as well. There are two cases:

  • "long-to-long": reshape by augmenting the indices

    case1

    Code:

    df = pd.DataFrame({'A': [1, 1, 1, 2, 2, 2], 'B': [*'xxyyzz'], 
                       'C': [*'CCDCDD'], 'E': [100, 200, 300, 400, 500, 600]})
    rows, cols, vals = ['A', 'B'], ['C'], 'E'
    
    # using pivot syntax
    df1 = (
        df.assign(ix=df.groupby(rows+cols).cumcount())
        .pivot(index=[*rows, 'ix'], columns=cols, values=vals)
        .fillna(0, downcast='infer')
        .droplevel(-1).reset_index().rename_axis(columns=None)
    )
    
    # equivalently, using set_index + unstack syntax
    df1 = (
        df
        .set_index([*rows, df.groupby(rows+cols).cumcount(), *cols])[vals]
        .unstack(fill_value=0)
        .droplevel(-1).reset_index().rename_axis(columns=None)
    )
    
  • "long-to-wide": reshape by augmenting the columns

    case2

    Code:

    df1 = (
        df.assign(ix=df.groupby(rows+cols).cumcount())
        .pivot(index=rows, columns=[*cols, 'ix'])[vals]
        .fillna(0, downcast='infer')
    )
    df1 = df1.set_axis([f"{c[0]}_{c[1]}" for c in df1], axis=1).reset_index()
    
    # equivalently, using the set_index + unstack syntax
    df1 = (
        df
        .set_index([*rows, df.groupby(rows+cols).cumcount(), *cols])[vals]
        .unstack([-1, *range(-2, -len(cols)-2, -1)], fill_value=0)
    )
    df1 = df1.set_axis([f"{c[0]}_{c[1]}" for c in df1], axis=1).reset_index()
    
  • minimum case using the set_index + unstack syntax:

    case3

    Code:

    df1 = df.set_index(['A', df.groupby('A').cumcount()])['E'].unstack(fill_value=0).add_prefix('Col').reset_index()
    

1 pivot_table() aggregates the values and unstacks it. Specifically, it creates a single flat list out of index and columns, calls groupby() with this list as the grouper and aggregates using the passed aggregator methods (the default is mean). Then after aggregation, it calls unstack() by the list of columns. So internally, pivot_table = groupby + unstack. Moreover, if fill_value is passed, fillna() is called.

In other words, the method that produces pv_1 is the same as the method that produces gb_1 in the example below.

pv_1 = df.pivot_table(index=rows, columns=cols, values=vals, aggfunc=aggfuncs, fill_value=0)
# internal operation of `pivot_table()`
gb_1 = df.groupby(rows+cols)[vals].agg(aggfuncs).unstack(cols).fillna(0, downcast="infer")
pv_1.equals(gb_1) # True

2 crosstab() calls pivot_table(), i.e., crosstab = pivot_table. Specifically, it builds a DataFrame out of the passed arrays of values, filters it by the common indices and calls pivot_table(). It's more limited than pivot_table() because it only allows a one-dimensional array-like as values, unlike pivot_table() that can have multiple columns as values.

如何旋转数据框?

冷血 2025-02-14 09:49:08
here is you add in css  `#container{height:100%}` you can replace `height:100%;` to "`min-height:100%;`"

var canvas = document.querySelector("canvas");
fitToContainer(canvas);

function fitToContainer(canvas) {
  // Make it visually fill the positioned parent
  canvas.style.width = "100%";
  canvas.style.height = "100%";
  // ...then set the internal size to match
  canvas.width = canvas.offsetWidth;
  canvas.height = canvas.offsetHeight;
}
* {
     margin: 0;
     padding: 0;
}
 html, body {
     height: 100%;
     font-size: 16px;
     font-family: "Inter", sans-serif;
}
 #container {
     min-height: 100%;
     display: flex;
     align-items: center;
     justify-content: center;
}
 #container #content {
     outline: 2px solid #000;
     width: 80%;
     height: 80%;
}
 #container #content #menu {
     padding: 1em;
     border-bottom: 2px solid black;
}
 #container #content #menu select {
     padding: 1em;
}
 #container #content #menu a {
     background-color: #5b86c3;
     text-decoration: none;
     font-weight: bold;
     padding: 0.8em;
     color: white;
}
 #container #content #menu a:hover {
     background-color: #4b7abd;
}
 #container #content #canvas-container {
     width: 100%;
     height: 100%;
}
 #container #content #canvas-container canvas {
     outline: 2px solid green;
}
 
<div id="container">
  <div id="content">
    <div id="menu">
      ...
    </div>
    <div id="canvas-container">
      <canvas>

      </canvas>
    </div>
  </div>
</div>

here is you add in css  `#container{height:100%}` you can replace `height:100%;` to "`min-height:100%;`"

var canvas = document.querySelector("canvas");
fitToContainer(canvas);

function fitToContainer(canvas) {
  // Make it visually fill the positioned parent
  canvas.style.width = "100%";
  canvas.style.height = "100%";
  // ...then set the internal size to match
  canvas.width = canvas.offsetWidth;
  canvas.height = canvas.offsetHeight;
}
* {
     margin: 0;
     padding: 0;
}
 html, body {
     height: 100%;
     font-size: 16px;
     font-family: "Inter", sans-serif;
}
 #container {
     min-height: 100%;
     display: flex;
     align-items: center;
     justify-content: center;
}
 #container #content {
     outline: 2px solid #000;
     width: 80%;
     height: 80%;
}
 #container #content #menu {
     padding: 1em;
     border-bottom: 2px solid black;
}
 #container #content #menu select {
     padding: 1em;
}
 #container #content #menu a {
     background-color: #5b86c3;
     text-decoration: none;
     font-weight: bold;
     padding: 0.8em;
     color: white;
}
 #container #content #menu a:hover {
     background-color: #4b7abd;
}
 #container #content #canvas-container {
     width: 100%;
     height: 100%;
}
 #container #content #canvas-container canvas {
     outline: 2px solid green;
}
 
<div id="container">
  <div id="content">
    <div id="menu">
      ...
    </div>
    <div id="canvas-container">
      <canvas>

      </canvas>
    </div>
  </div>
</div>

是什么导致我的画布元素溢出,我该怎么办才能修复它?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文