alpha-shape 相关问题


单击 p 标签旁边的按钮时获取 p 标签的内部文本(无 Jquery)

我有几个盒子,每个盒子都包含按钮和一个 元素,其内部文本是由 API 中的数据创建的。我在每个框上放置了一个 onclick(包裹 的 ) 我有几个盒子,每个盒子都包含按钮和一个 <p> 元素,其内部文本是由 API 中的数据创建的。我在每个框上放置了一个 onclick(包裹 <div> 元素和按钮的 <p>)。我希望每次单击该按钮时,位于该按钮旁边(位于同一 div 中)的 innerText 标签的 <p> 都会控制台日志。目前无法弄清楚,这就是我到目前为止所得到的: const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => data.results.map(item => { return containerShapes.innerHTML += `<div class="shape-box" onclick="showName(event)"> <p>${item.name}</p> <button>Select</button> </div>` })) function showName(e) { console.log() } #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"> </div> </body> 您可以使用最近的。当您需要 forEach 或正确使用地图时也不要使用地图 我还强烈建议授权(点击 div) const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => containerShapes.innerHTML = data.results .map(({name}) => `<div class="shape-box"> <p>${name}</p> <button>Select</button> </div>`)); containerShapes.addEventListener("click", e => { const tgt = e.target.closest("button") if (tgt) console.log(tgt.closest("div.shape-box").querySelector("p").innerText) }) #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"></div> </body> 要获取名称,由于事件位于整个 div 上,因此您需要使用 querySelector 并找到内部 <p> 元素并获取其文本。 const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => data.results.map(item => containerShapes.innerHTML += `<div class="shape-box" onclick="showName(this)"> <p>${item.name}</p> <button>Select</button> </div>` )) function showName(box) { const name = box.querySelector('p').textContent; console.log(name); } #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"></div> </body> 执行此操作的另一种方法是将单击事件仅添加到按钮,然后查找 closest 形状框,然后找到 <p>。 const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => data.results.map(item => containerShapes.innerHTML += `<div class="shape-box"> <p>${item.name}</p> <button onclick="showName(this)">Select</button> </div>` )) function showName(button) { const name = button.closest('.shape-box').querySelector('p').textContent; console.log(name); } #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"></div> </body> 嘿,我最近找到了解决此问题的简单方法(当然,如果您的文本不像按钮文本那样太长):您可以将内部文本作为元素的 id 提供。并且在事件处理程序中,您可以通过以下方式访问内部文本:这样:e.target.id希望这个解决方案可以帮助你:)


与仅使用 lambda 相比,lambdametafactory 创建速度相当慢

@Benchmark 公共无效testLambdaGeneration(黑洞bh){ 函数函数 = a -> { if(Alpha alpha 的一个实例) { 返回 alpha.primitiveInt(); ...


branch 不是使用 yup 模式与 when 和 then 进行反应的函数

在使用 yup 进行反应时,我创建了这个模式 const RefereeFormSchema = Yup.object().shape({ name: Yup.string().required('姓名为必填项'), 移动端:Yup.string().matches(APP_CONFIG.REGEX_PHO...


如何使用css制作如图所示的圆形波浪边框?

图像的右侧是问题所在,我无法将边框做成像这样的波浪。 我希望它弯曲但不对称。 这是我使用的最接近的(https://css-generators.com/wavy-shape...


RecyclerView 中 onBindView 上的 setAlpha() 在首次显示时不起作用

在 RecyclerView.Adapter 中使用以下代码: onBindViewHolder(VH 持有者, int 位置){ holder.itemView.setAlpha(0.5f); } 第一次显示该项目时不会显示 Alpha。哈...


如何在 THREE.js 中更改透明图像的背景?

https://codepen.io/joe1992/pen/yLQRwrg 在我的 Three.js 项目中,我想将 .png 文件应用于对象,但 Alpha 通道不允许底层对象的颜色显示出来;这是...


如何在 R 中编码,这个对数似然函数

给出了一个有序的logit模型; 考虑 Logit 模型的以下对数似然函数: 还给出 k = {0,1,2,3,4},其中对于 k = 0 & k = 4,我们的 alpha 为 -Inf 和 +Inf


运行 json-server --watch 时出现意外错误和警告

我尝试使用 json-server,如下所示: $ json-server --watch db.json 但是,当我运行该命令时,我收到错误或警告,具体取决于我安装的版本: 1.0.0-alpha.1-1...


在Three.js中加载透明背景的图像可能会导致表面消失[关闭]

https://codepen.io/joe1992/pen/yLQRwrg 在我的 Three.js 项目中,我想将 .png 文件应用于对象,但 Alpha 通道不允许底层对象的颜色显示出来;这是...


更改UITabBar图标的颜色

我想将UI选项卡栏图标颜色更改为以下值:红色:0.75,绿色:1.0,蓝色:1.0,Alpha:1.0,并且在未选择图标时将其更改为白色。 到目前为止,我认为这就是你的做法:


如何在 RecyclerView Adapter Android 中设置启用或禁用视图

在我的应用程序中,我想使用 Recyclerview 并显示来自服务器的一些数据。 服务器发送给我时间,我应该检查现在的时间,如果服务器时间小于现在时间,我应该为此设置 alpha。 我写


是否有人尝试在 Tableau 上将 monday.com 连接器数据源中的项目与外部数据集(例如 Excel 电子表格)连接或混合?

我正在尝试将通过 Alpha Serve 连接的板和项目与包含互补数据并共享相同字段的 Excel 电子表格连接起来。找不到任何创建加入的选项...


android 高度隐藏布局的所有视图

我的布局如下面的屏幕截图所示。 我的代码如下。 我的布局如下面的屏幕截图所示。 我的代码如下。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" > <LinearLayout android:id="@+id/ll_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_smallxx" android:layout_marginTop="@dimen/margin_normalxx" android:layout_marginEnd="@dimen/margin_smallxx" android:orientation="vertical"> ....... 现在我想为盒子添加阴影,如下所示。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" > <TextView style="@style/shadowStyle" android:elevation="20dp" android:layout_alignTop="@id/ll_main" android:layout_alignBottom="@id/ll_main" android:layout_alignStart="@id/ll_main" android:layout_alignEnd="@id/ll_main" /> <LinearLayout android:id="@+id/ll_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_smallxx" android:layout_marginTop="@dimen/margin_normalxx" android:layout_marginEnd="@dimen/margin_smallxx" android:orientation="vertical"> shadowStyle如下。 <style name="shadowStyle" parent="@android:style/TextAppearance"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">match_parent</item> <item name="android:text"></item> <item name="android:background">@drawable/myrect</item> <item name="android:outlineSpotShadowColor">@color/shadow_color</item> </style> 和myrect.xml形状如下。 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFF" /> <corners android:radius="20dp" /> </shape> 当我添加此内容时,下面的所有视图都会被隐藏,这很奇怪。 应用程序截图如下。 我将 shadow_color 表示为 #FF00FF 仅用于测试目的。 知道如何使其正确吗?我是不是错过了什么... 以下是我根据mãĴď评论所做的事情 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/white"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_smallxx" android:layout_marginTop="@dimen/margin_normalxx" android:layout_marginEnd="@dimen/margin_smallxx" app:cardCornerRadius="10dp" app:cardElevation="20dp" android:outlineSpotShadowColor="@color/shadow_color" > <LinearLayout android:id="@+id/ll_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> ........ </LinearLayout> </CardView> </RelativeLayout> 这意味着我们将拥有卡片视图并将整个布局放入其中......


如何让div在透明背景上有纯色?

<!DOCTYPE html> <html lang="pl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="style.css"> </head> <body> <div id="bg"> <div id="topbar"></div> </div> </body> </html> body { background: url(bg.jpg); margin: 0; } #bg { background-color: black; margin: 0; padding: 0; height: 100vh; opacity: 0.7; } #topbar { background-color: gray; height: 80px; width: 100%; } Ive tried adding opacity: 1 to the topbar div and rgba with alpha: 1. The result: there是一个图像,其上有黑色背景,不透明度为 0.7,顶部栏的不透明度也为 0.7。 我的目标是实现较暗的图像作为背景和纯色顶栏 div #topbar位于#bg内部,因此调整#bg的不透明度也会影响#topbar。我要做的是省略不透明度并将背景颜色更改为透明黑色。 看起来像这样: body { background: url(bg.jpg); margin: 0; } #bg { background-color: rgba(0, 0, 0, 0.7); margin: 0; padding: 0; height: 100vh; } #topbar { background-color: gray; height: 80px; width: 100%; } 这样只有背景颜色是透明的,而不是整个元素。


引导行不占据 100% 宽度

我有一个引导网格布局,但行没有占据 100% 宽度。我正在使用 Bootstrap 4 alpha 6。这是 HTML: 我有一个引导网格布局,但该行未占据 100% 宽度。我正在使用 Bootstrap 4 alpha 6。这是 HTML: <div class="container-fluid"> <h1 class="center-text" id="heading">[Enter Heaading Here]</h1> <div class="container"> <div height="100px" class="row border-show"> <div class="col-4" id="one"></div> <div class="col-4" id="two"></div> <div class="col-4" id="three"></div> </div> </div> </div> 这是CSS: .center-text{ text-align: center; } #heading{ padding: 60px; } .border-show{ border-style: solid; border-color: black; } 万一其他人遇到这个问题并且答案不能解决他们的问题,导致此问题的问题是因为我没有意识到我正在添加一行并尝试在 Bootstrap 导航栏中设置列。默认情况下,导航栏已经有一个类似网格的系统,因此如果您尝试在其中添加列,那么您似乎将其推到了边缘。无论如何,它们都没有必要。 因此,如果这个答案不能解决您的问题,请检查您是否位于另一个已经处理间距的 Bootstrap 组件内。您可能正在尝试对您的内容进行双重定界! 将其从container中取出。 container 不是 100% 宽度,不应嵌套在另一个容器中。 container类有这样的效果。 <div class="container"> <div class="row"> <div class="col-12"> div into <b>container</b> class </div> </div> </div> <div class="container-fluid"> <div class="row"> <div class="col-12"> div into <b>container-fluid</b> class </div> </div> </div> 此代码将生成以下图像: 在我的例子中,甚至容器流体也不起作用,因为我在同一 div 中使用了带有容器流体的行类。因此,我从父 div 中删除了行类,并在其中创建了一个子 div 并使用了行类。然后就成功了。 <div class="container-fluid row"> <div class="col-12"> didn't work </div> </div> <div class="container-fluid"> <div class="row"> <div class="col-12"> worked </div> </div> </div> 我刚刚遇到了类似的挑战,嵌入式 iframe 没有占据整行。我正在使用 bootstrap 5。以下是让 iframe 占据 100% 宽度并具有响应能力的方法: <div class="row"> <div class="ratio ratio-16x9"> <iframe src="https://www.youtube.com/embed/cTp3w2ZUUxw?rel=0" allowfullscreen></iframe> </div> </div> ratio和ratio-16x9是Bootstrap 5中的新功能,使这一切变得超级简单。


© www.soinside.com 2019 - 2024. All rights reserved.