color-theory 相关问题


WinUI 3 嵌套资源字典?

可以嵌套多级字典吗?像这样的东西: 可以嵌套多级字典吗?像这样的东西: <?xml version="1.0" encoding="utf-8"?> <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Dark"> <ResourceDictionary x:Key="Button1"> <SolidColorBrush x:Key="ButtonBackground" Color="HotPink" /> <SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="HotPink" /> <SolidColorBrush x:Key="ButtonBackgroundPressed" Color="HotPink" /> <SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="HotPink" /> <SolidColorBrush x:Key="ButtonForeground" Color="White" /> <SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="White" /> <SolidColorBrush x:Key="ButtonBorderBrush" Color="White" /> <SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="White" /> <SolidColorBrush x:Key="ButtonBorderBrushFocused" Color="White" /> <SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="White" /> </ResourceDictionary> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries> </ResourceDictionary> 是否可以以某种方式访问Button1字典? ResourceDictionary 应该添加到 MergedDictionary 中,所以你不能使用这个 <ResourceDictionary x:Key="Dark"> <ResourceDictionary x:Key="Button1"> 如果您想为按钮定义多种样式,您应该这样做: <ResourceDictionary x:Key="Light"> <Style x:Key="Button1"


ngx-color-picker 安装出现错误

我正在尝试按照以下说明在我的 Angular 应用程序中安装 ngx-color-picker: https://www.npmjs.com/package/ngx-color-picker/v/16.0.0 使用下面的命令安装它是有效的


如何将 com.google.android.material.textfield.TextInputEditText 制作为文本视图?

<com.google.android.material.textfield.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="32dp" android:layout_marginTop="16sp" android:layout_marginEnd="32dp" app:boxStrokeColor="@color/blue"> <com.google.android.material.textfield.TextInputEditText android:layout_width="match_parent" android:layout_height="wrap_content" android:fontFamily="@font/quicksand_bold" android:hint="Full Name" android:textColor="@color/blue" android:textColorHint="@color/blue" /> </com.google.android.material.textfield.TextInputLayout> 我将其用于 Edittext,但我不知道如何将其用于 Textview android:focusable="false" android:clickable="false" android:cursorVisible="false" 将其添加到EditText


.NET MAUI 中的 Shell 背景渐变

知道如何为 Shell 提供渐变背景吗? 我尝试在 Shell 背景上定义 LinearGradientBrush 但这不起作用。 知道如何为 Shell 提供渐变背景吗? 我尝试在 Shell 背景上定义 LinearGradientBrush,但这不起作用。 <?xml version="1.0" encoding="UTF-8" ?> <Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <Shell.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </Shell.Background> <FlyoutItem FlyoutDisplayOptions="AsMultipleItems"> <!-- FlyoutItem contents here --> </FlyoutItem> </Shell> 我已经确认这是为 Shell.Background 设置渐变时的已知问题,请参阅 Shell.Background - Gradient does not work #10445,您可以按照该线程进行操作。 幸运的是,您可以单独设置渐变背景。如果您有“外壳”弹出窗口,则可以为“外壳”弹出项目设置渐变背景: <Shell.FlyoutBackground> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </Shell.FlyoutBackground> 另外,如果要将 ShellContent 背景设置为渐变背景,可以将渐变背景添加到 ContentPage 的背景属性中。 <ContentPage.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </ContentPage.Background> 希望这有帮助!


这些链接颜色在 CSS 继承方面的表现如何?

身体{ 颜色:绿色; } .my-class-1 a { 颜色:继承; } .my-class-2 a { 颜色:初始; } .my-class-3 a { 颜色:未设置; } 默认链接 body { color: green; } .my-class-1 a { color: inherit; } .my-class-2 a { color: initial; } .my-class-3 a { color: unset; } <ul> <li>Default <a href="#">link</a> color</li> <li class="my-class-1">Inherit the <a href="#">link</a> color</li> <li class="my-class-2">Reset the <a href="#">link</a> color</li> <li class="my-class-3">Unset the <a href="#">link</a> color</li> </ul> 默认链接颜色 继承链接颜色 重置链接颜色 取消链接颜色 我正在从 MDN Web Docs 网站学习 Web 开发,当我试图理解 CSS 中的继承概念时,我陷入了困境。 网站上提供了 HTML 和 CSS 代码,并提供了其结果。结果是各种链接的颜色取决于应用于它们的类和继承。我无法理解 CSS 如何影响链接的颜色。 来自 MDN Web Docs 网站的网页 代码及其结果已经提供给我了。我只是想了解这种行为。 默认链接颜色 <a>元素在浏览器具有的默认样式中显示为蓝色,称为用户代理样式表。大多数浏览器在其用户代理样式表中都有一个 CSS 规则,大致相当于: a { color: blue; } 继承链接颜色 让我们自上而下地工作,以更好地理解这个案例。 在 CSS 或大多数用户代理样式表中,<ul> 没有显式应用 color。如果我们看一下 color 属性的 正式定义,我们可以看到: 继承 是的 如果我们随后参考继承文档,它会说: 如果未在元素上指定继承属性的值,则该元素将获取其父元素上该属性的计算值。 因此,对于 <ul>,由于它实际上没有为其 color 属性设置显式值,因此它继承自 <body>,其(计算出的)color 值为 green。 <ul> 元素的 color 属性被 计算 为 green。 对于 li.my-class-1,它再次没有为其 color 属性设置显式值(来自作者或用户代理样式表),因此它继承自 <ul>,其(计算出的)color 值为 green 。 li.my-class-1 元素的 color 属性被 计算 为 green。 对于 <a> 内的 li.my-class-1 元素,它的 inherit 属性具有 color 值,这意味着它继承自其父级 <li>,其(计算出的)color 值为 green。因此,<a>元素的color属性被计算为green。 重置链接颜色 我们可以从 initial 的 MDN 文档中了解 initial 的值意味着什么: initial CSS 关键字将属性的初始(或默认)值应用于元素。 此外,初始(或默认)值定义为: CSS属性的初始值是其默认值,如规范中其定义表中所列。 如果我们查看 color 属性的 正式定义,我们可以看到: canvastext 初始值 因此,<a>元素的color值为canvastext。这是一个系统颜色,定义为: CanvasText应用程序内容或文档中的文本颜色 对于“典型”设置,这相当于 black。因此 color: initial 等价于 color: black,因此为什么 <a> 元素是彩色的 black。取消设置链接颜色 我们可以从 unset 的 MDN 文档中了解 unset 的值意味着什么: 如果属性自然继承自其父级,则 unset CSS 关键字会将属性重置为其继承值;如果不是,则重置为其初始值。 如果我们查看 color 属性的 正式定义,我们可以看到: 继承 是的 因此,color元素的<a>属性遵循与color: inherit相同的行为,如前面详细介绍的继承链接颜色部分中所指定。


MAUI 8 - 如何更改弹出背景叠加颜色?

使用 MAUI 7.0,下一个代码允许更改弹出背景叠加颜色,但该代码不适用于 MAUI 8.0 使用 MAUI 7.0,下一个代码允许更改弹出窗口背景覆盖颜色,但该代码不适用于 MAUI 8.0 <maui:MauiWinUIApplication x:Class="TestMaui8.WinUI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:maui="using:Microsoft.Maui" xmlns:local="using:TestMaui8.WinUI"> <maui:MauiWinUIApplication.Resources> <Color x:Key="SystemAltMediumColor">Transparent</Color> <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogBackgroundThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <StaticResource x:Key="ContentDialogBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <StaticResource x:Key="PopupLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <SolidColorBrush x:Key="SliderBorderBrush" Color="#1A73E8" /> <Style TargetType="Slider"> <Setter Property="BorderBrush" Value="{StaticResource SliderBorderBrush}"/> </Style> </maui:MauiWinUIApplication.Resources> </maui:MauiWinUIApplication> 有人知道为什么它不起作用以及如何修复它吗? 更新添加一些图片 CommunityToolkit Popup 没有 Overlay color 功能。您可以在 CommunityToolkit GitHub 页面上提出功能请求。 是的,您发布的上述代码曾经可以工作,但它不适用于具有最新 CommunityToolkit.Maui nuget 的 .NET8。 但是如果您想更改叠加颜色,这里有一个解决方法。 <toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui" ... Color="Black" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" > //make the size to be the full screen size <ContentView WidthRequest="1920" HeightRequest="1080"> <VerticalStackLayout WidthRequest="300" HeightRequest="300" BackgroundColor="Green"> <Image Source="dotnet_bot.png"/> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> </VerticalStackLayout> </ContentView> </toolkit:Popup>


Python 字典不同的键名称

是否可以循环遍历Python字典并输出此输出 prods = {'product_1': {'color': '白色', 'whls': '25.00', 'size_3': '0', 'size_4': '14', 'size_5': '35'}, '产品...


VueJS [电子邮件受保护] 组件 v-model 最初不会更新父级

我有一个父子组件设置来测试 v-model。当您输入值时,子级会更新父级,但最初不会。 家长: 从“vue”导入{ref}; 导入文本输入...</desc> <question vote="0"> <p>我有一个父子组件设置来测试 v-model。当您输入值时,子级会更新父级,但最初不会。</p> <p>家长:</p> <pre><code>&lt;script setup&gt; import { ref } from &#39;vue&#39;; import TextInput from &#39;./TextInput.vue&#39;; const size = ref(1); const color = ref(&#39;red&#39;); &lt;/script&gt; &lt;template&gt; &lt;TextInput v-model:size=&#34;size&#34; v-model:color.capitalize=&#34;color&#34; /&gt; &lt;div :style=&#34;{ fontSize: size + &#39;em&#39;, color: color }&#34;&gt; &lt;!-- Question 1: this line shows &#34;red&#34; but &#34;Red&#34; is what I want initially --&gt; &lt;p&gt;{{ size }} {{ color }}&lt;/p&gt; &lt;/div&gt; &lt;/template&gt; </code></pre> <p>子:TextInput.vue</p> <pre><code>&lt;script setup&gt; import { ref } from &#39;vue&#39;; const size = defineModel(&#39;size&#39;); const [color, modifier] = defineModel(&#39;color&#39;, { set(value) { if(modifier.capitalize) { return value.charAt(0).toUpperCase() + value.slice(1); } return value; }, //only this forces color to upper case on start in the input get(value) { if(modifier.capitalize) { return value.charAt(0).toUpperCase() + value.slice(1); } return value; } }); &lt;/script&gt; &lt;template&gt; &lt;input v-model=&#34;size&#34;&gt; &lt;input v-model=&#34;color&#34;&gt; &lt;/template&gt; </code></pre> <p>问题2: 如果我在defineModel中省略“color”(“color”,{...,我会收到以下错误</p> <p>[Vue warn]:无关的非 props 属性(颜色、colorModifiers)被传递给组件但无法自动继承,因为组件渲染片段或文本根节点。</p> <pre><code>at &lt;TextInput size=1 onUpdate:size=fn color=&#34;red&#34; ... &gt; at &lt;ComponentVModel&gt; at &lt;App&gt; </code></pre> <p>如果我只保留</p> <pre><code>&lt;input v-model=&#34;color&#34;&gt; </code></pre> <p>line,为了让它不是片段,根本不更新。</p> </question> <answer tick="false" vote="0"> <p>问题 1:在调用子元素中的 v-model setter 之前,<pre><code>&lt;p&gt;</code></pre> 元素中的大写不会发生。 <strong>设置器是同步回父级的设置器</strong>。由于在输入接收到来自用户的一些文本之前不会调用设置器,因此父级中的 <pre><code>&lt;p&gt;</code></pre> 元素将显示初始值,在您的情况下为“红色”。</p> <p>问题 2:defineModel 根据第一个参数字符串“color”声明一个 prop。该道具旨在匹配父级<strong>上的</strong>v模型的参数,即<pre><code>v-model:color</code></pre>。从defineModel中删除“颜色”意味着父v模型必须从<pre><code>v-model:color</code></pre>更改为<pre><code>v-model</code></pre></p> </answer> </body></html>


Select2 中的样式选择选项

问题是如何在选项的一部分上应用样式。 我有一个像这样的选择: 项目 1 问题是如何在选项的一部分上应用样式。 我有一个像这样的选择: <select id="my_select"> <option value="1">Item 1 <span class="color-red">20 calls</span></option> <option value="2">Item 2 <span class="color-red">10 calls</span></option> <option value="2">Item 3 <span class="color-red">30 calls</span></option> </select> 浏览器不允许在 OPTION 中使用标签并删除它们。 因此,一个可能的解决方法是使用 HTML 实体: <select id="my_select"> <option value="1">Item 1 &lt;span class="color-red"&gt;20 calls&lt;/span&gt;</option> <option value="2">Item 2 &lt;span class="color-red"&gt;10 calls&lt;/span&gt;</option> <option value="2">Item 3 &lt;span class="color-red"&gt;30 calls&lt;/span&gt;</option> </select> 现在浏览器将每个选项的全部内容视为文本。这是 Jquery 代码: $('#my_select').select2({ minimumResultsForSearch: -1 }); 我偶然发现的最后一件事是在渲染 Select2 和下拉菜单后分别用“<" and ">”符号替换实体“<”和“">”,以默认黑色进入第一个选项框“Item 1”, “20 次通话”为红色(CSS 可用:.color-red {color:red;})。其他选项框也是如此。 我试图在文档中找到答案,但没有任何效果。例如, $('#my_select').select2({ minimumResultsForSearch: -1, templateResult: function (item) { item.text.replace (/&gt;/g,'>').replace (/&lt;/g,'<'); } }); 非常感谢任何有关如何解决此问题的想法。 您需要重写 escapeMarkup 选项以允许 HTML 内容。 在templateResult中,您告知要如何以及以何种方式呈现内容,在本例中,我在每个选项中使用数据文本属性的返回。 $('#my_select').select2({ minimumResultsForSearch: -1, escapeMarkup: function(item) { return item; }, templateResult: function(item) { return $(item.element).data('text'); } }); .color-red { color: #ff0000; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script> <select id="my_select" style="width: 100%;"> <option></option> <option value="1" data-text='Item 1 <span class="color-red">20 calls</span>'>Item 1 20 calls</option> <option value="2" data-text='Item 2 <span class="color-red">10 calls</span>'>Item 2 10 calls</option> <option value="3" data-text='Item 3 <span class="color-red">30 calls</span>'>Item 3 30 calls</option> </select>


在 ipynb 中运行代码时运行plotly.express 时出现错误

我在ipynb中编写了与视频类相同的代码: 将plotly.express导入为px grafico = px.histogram(tabela, x="duracao_contrato", color="cancelou",color_discrete_map="


R 的包装函数,带有可选参数[重复]

我有以下包装函数: 绘图.直方图 = 函数(x.var, y.var, pf) { ggplot(aes_string(x.var, y.var), 数据 = pf) + geom_bar(stat="identity", color = "black", fill = "steelblu...


带有边框半径和粘性标题的 HTML 表格

我有一个 HTML ,带有边框半径和使用位置的粘性标题:sticky,如下所示: https://codepen.io/muhammadrehansaeed/pen/OJpeeKP 但是,当使用 滚动时 我有一个带有 <table> 的 HTML border-radius 和使用 position: sticky 的粘性标题,如下所示: https://codepen.io/muhammadrehansaeed/pen/OJpeeKP 但是,当使用粘性标题滚动时,表格行会伸出粘性标题的圆角所在的位置。请参阅此图片的左上角: 有没有办法可以在使用粘性标题向下滚动时保持圆角,或者在标题变得粘性并从原始位置向下移动时删除粘性标题?理想情况下,我想要一个CSS解决方案。 您可以使用伪元素隐藏边框的某些部分: table thead th:first-child::before, table thead th:last-child::after { width: 1px; height: 5px; background: white; content: ""; display: block; position: absolute; top: 0px; } table thead th:first-child::before { left: -1px; } table thead th:last-child::after { right: -1px; } 正如Ivan建议的那样,似乎使用伪元素来覆盖标题下方不需要的边框是(令人惊讶的)唯一可行的选择。我建议使用伪不仅用于覆盖“外部”区域,而且还用于绘制弧线和填充“内部”区域。可以使用堆叠背景来做到这一点。应用于原始代码: /* § Additions / Changes */ table thead th { position: relative; } /* Pseudos exceeding header boundary by border width; with rectangle covering half circle and rest of height */ table thead th:last-child::after, table thead th:first-child::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(-1 * var(--global-border-width-1)); width: var(--global-border-radius); background-image: linear-gradient(to bottom, transparent var(--global-border-radius), var(--global-title-color) 0), radial-gradient(circle at var(--global-border-radius) var(--global-border-radius), var(--global-title-color) var(--global-border-radius), var(--global-content-background-color) 0); background-position: top left; background-size: var(--global-border-diameter) 100%, var(--global-border-diameter) var(--global-border-diameter); background-repeat: no-repeat; } table thead th:last-child::after { left: auto; right: calc(-1 * var(--global-border-width-1)); background-position: top right; } /* § Declarations and original style */ html { --global-content-background-color: white; --global-title-color: black; --global-background-color: lightblue; --global-border-color: black; --global-border-radius: 20px; --global-border-width-1: 10px; --global-space-fixed-2: 10px; --global-space-fixed-3: 15px; --global-border-diameter: calc(2 * var(--global-border-radius)); background-color: var(--global-content-background-color); } table { color: var(--global-title-color); background-color: var(--global-content-background-color); border-collapse: separate; border-color: var(--global-title-color); border-style: solid; border-radius: var(--global-border-radius); border-width: 0 var(--global-border-width-1) var(--global-border-width-1) var(--global-border-width-1); border-spacing: 0; width: 100%; } table thead { position: sticky; top: 0; z-index: 10; } table thead th { color: var(--global-background-color); background-color: var(--global-title-color); padding: var(--global-space-fixed-2) var(--global-space-fixed-3); vertical-align: bottom; } table tbody td { border-top: var(--global-border-width-1) solid var(--global-border-color); padding: var(--global-space-fixed-2) var(--global-space-fixed-3); vertical-align: top; } table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--global-border-radius); } table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--global-border-radius); } /* § Unrelated / demo */ * { scroll-margin-top: calc(var(--global-space-fixed-2) * 4 + 1rem); /* = height of sticky thead + top padding of cell, provided text in thead does not wrap */ scroll-margin-bottom: 1em; } td { height: 60vh; } td a { float: right } tr:last-child td { vertical-align: bottom; } a[name]:empty::before { content: attr(name); } th:not(#\0):hover::before { background-image: linear-gradient(to bottom, transparent var(--global-border-radius), #0F08 0), radial-gradient(circle at center, #00F8 var(--global-border-radius), #F2F4 0); background-position: top left; background-size: var(--global-border-diameter) 100%, var(--global-border-diameter) var(--global-border-diameter); } <table> <thead> <tr> <th>Fake non-transparent "border-radius"</th> </tr> </thead> <tbody> <tr> <td> <a href="#⬆️" name="⬇️"></a> For fixed header</td> </tr> <tr> <td> <a href="#⬇️" name="⬆️"></a> Using CSS stacked background images in pseudo elements</td> </tr> </tbody> </table> 只需从表格中删除边框,并为表格主体中的第一个和最后一个表格单元格添加左右边框: tbody td:first-child { border-left: 1px solid black; } tbody td:last-child { border-right: 1px solid black; } tbody tr:last-child td{ border-bottom: 1px solid black; } tbody tr:last-child td:first-child { border-bottom-left-radius: 2px; } tbody tr:last-child td:last-child { border-bottom-right-radius: 2px; } 当然是使用适当的缩进、嵌套和变量! 使用许多伪选择器看起来样式相当丑陋,但似乎可以解决您的问题。 有一个更紧凑的解决方案。只需将具有背景颜色的框阴影添加到第一个 < th > 和最后一个 < th > 即可隐藏元素。 在此示例中,在右侧,您可以看到表格行由于边框半径而可见。在左边,我应用了盒子阴影。 盒子阴影:0 -2.1rem 0 .6rem #E5E7EB; 在这里,它是灰色的,以便您可以看到它的工作原理,但您只需使用与背景相同的颜色即可使其完全不可见。 这是最终结果以及我正在使用的代码: th:第一个孩子 { 边界半径:0.75rem 0 0 0; 左边框:.1rem 实心 $color-gray-200; 框阴影:0 -2.1rem 0 .6rem $color-gray-200; } th:最后一个孩子{ 边界半径:0 0.75rem 0 0; 右边框:.1rem 实心 $color-gray-200; 盒子阴影:1rem -2.1rem 0 .6rem $颜色白色; } 可能需要调整框阴影以隐藏基于所选边框半径的行。 不确定你是否熟悉jquery,如果熟悉的话你可以在滚动内容时动态更改 border-top-left-radius: 等于粘性标题的半径,但这对于新手来说有点棘手jquery/JS。 其次,您可以将粘性标题封闭到父级(例如class="parent")),并将父级背景设置为白色,没有边框。并保持粘性标题的边框半径不变。因此,当您滚动内容时将位于该父级下方(例如 class="parent")。为了确保父级出现在该行上方,您可以给出 z-index: 10


如何删除颜色输入的边框?

我使用 JavaScript 生成的 HTML5 颜色选择器元素来让用户设置另一个元素的颜色。当浏览器执行 input type="color" 时,它会绘制一个显示


如何让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%; } 这样只有背景颜色是透明的,而不是整个元素。


如何去除特定元素的 :hover 效果?

首页 &... <div class="menu-bar"> <ul> <li><a href="/Home/index.html"> <i class="fa fa-house"></i>Home</a> </i></li> < ul > </div> <style> .menu-bar ul li a:hover { color: black; transition: all 0.2s; border-inline-end: 2px solid; border-block-end: 2px solid; </style> 我想从 fa fa-house 的 cdn 图标中删除 :hover 效果。 <div class="menu-bar"> <ul> <li> <i class="fa fa-home"></i> <a href="/Home/index.html"> Home </a> </li> </ul> </div> <style> .menu-bar ul li a:hover { color: black; transition: all 0.2s; border-inline-end: 2px solid; border-block-end: 2px solid; } .menu-bar ul li i{ pointer-events: none; } </style> <div class="menu-bar"> <ul> <li><i class="fa fa-house"></i><a href="/Home/index.html"> Home</a> </i></li> <ul > 只需从 <i> 标签中取出 <a> 元素(图标)即可。 你可以试试这个:- <div class="menu-bar"> <ul> <li><i class="fa fa-house"><a href="/Home/index.html"> </i>Home</a> </i></li> </ul> </div> <style> .menu-bar ul li a:hover { color: black; transition: all 0.2s; border-inline-end: 2px solid; border-block-end: 2px solid; } </style>


MatToolbar:尝试组合不同的工具栏模式

出现以下错误: MatToolbar:尝试组合不同的工具栏模式。显式指定多个 元素或仅将内容放置在 中 出现以下错误: MatToolbar:尝试组合不同的工具栏模式。要么显式指定多个 <mat-toolbar-row> 元素,要么仅将内容放置在单行的 <mat-toolbar> 中。 我的代码已经在 mat-toolbar 中应用了 mat-toolbar-row。然而,该错误仍然存在。 html文件的代码片段如下: <div class="wallpaper"> <mat-toolbar color="primary"> <mat-toolbar-row> <span>Welcome, User</span> <span class="example-fill-remaining-space"></span> <span class="align-center"></span> <span class="example-spacer"></span> <button mat-button>Create Incident </button> <a [routerLink]="['/closed']"><button mat-button style="color: white">Closed Incident</button></a> <span class="example-spacer"></span> <a [routerLink]="['/login']"><button mat-button>Logout</button></a> <img src="../../assets/hsbc_logo3.png" class="logo-hsbc"/> </mat-toolbar-row> <h1>INCIDENT MANAGEMENT SYSTEM</h1> </mat-toolbar> <h1>Welcome to Incident Management System</h1> <mat-card style="background: transparent"> <!-- Title of an Card --> <mat-card-title>Incident Details</mat-card-title> <mat-card-content> <form> <table > <tr> <td> <mat-form-field class="demo-full-width"> <mat-label >Description</mat-label> <textarea [(ngModel)]="incident.description" name="description" cdkTextareaAutosize cdkAutosizeMinRows="1" cdkAutosizeMaxRows="5" matInput></textarea> </mat-form-field> </td> <td> <h4>{{message}}</h4> </td> </tr> <tr> <td> <mat-form-field class="demo-full-width"> <input matInput [matDatepicker]="picker" placeholder="Incident Date" [(ngModel)]="incident.date" name="date" > <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle> <mat-datepicker touchUi="true" #picker></mat-datepicker> </mat-form-field> </td> </tr> <tr> <td colspan="2"> <mat-form-field class="demo-full-width"> <input matInput placeholder="Incident Category" [(ngModel)]="incident.category" name="category"> </mat-form-field> </td> </tr> <tr> <td > <mat-form-field class="demo-full-width"> <mat-select placeholder="Application Owner" [(ngModel)]="incident.owner" name="owner"> <mat-option style="background-color:grey">-- Select--</mat-option> <mat-option style="background-color:cornsilk" value="1">BRV</mat-option> <mat-option style="background-color:cornsilk" value="2">FRTB</mat-option> <mat-option style="background-color:cornsilk" value="3">FSA</mat-option> </mat-select> </mat-form-field> </td> <td> <mat-form-field> <mat-select placeholder="Symphony Group" [(ngModel)]="incident.symphony_group" name="symphony_group"> <mat-option style="background-color:grey">-- Select --</mat-option> <mat-option style="background-color:cornsilk" value="1">MMO SheHacks</mat-option> <mat-option style="background-color: cornsilk" value="2">MMO IT INDIA</mat-option> </mat-select> </mat-form-field> </td> </tr> <tr> <td> <mat-form-field> <mat-select placeholder="Application" [(ngModel)]="incident.application" name="application"> <mat-option style="background-color:grey">-- Select--</mat-option> <mat-option style="background-color:cornsilk" value="1">BRV</mat-option> <mat-option style="background-color:cornsilk" value="2">FRTB</mat-option> <mat-option style="background-color:cornsilk" value="3">FSA</mat-option> </mat-select> </mat-form-field> </td> <td> <mat-form-field> <mat-select placeholder="Status" [(value)]="status" [(ngModel)]="incident.status" name="status"> <mat-option style="background-color:grey">-- Select --</mat-option> <mat-option style="background-color: green" value="1">Available</mat-option> <mat-option style="background-color: orange" value="2">Reduced</mat-option> <mat-option style="background-color: red" value="3">Unavailable</mat-option> </mat-select> </mat-form-field> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" class="content-center"> <button style="margin:5px" mat-raised-button color="accent" (click)="submit()">Submit Incident</button> <button style="margin:5px" mat-raised-button color="accent" (click)="reset()">Clear</button> <button style="margin:5px" mat-raised-button color="accent">Raise BGCR</button> <button style="margin:5px" mat-raised-button color="accent">Raise Jira</button> </td> </tr> </table> </form> </mat-card-content> </mat-card> </div> 您需要移除 <h1>INCIDENT MANAGEMENT SYSTEM</h1> 或将其放入 <mat-toolbar-row> 内。 我无法在垫子工具栏中填充图像 有什么帮助吗?


如何使用Windows批处理脚本每1秒更改cmd的文本颜色

颜色命令与更改 Windows 命令提示背景/文本的颜色有关 color 0A - 其中 0 是背景颜色,A 是文本颜色 我想改变这些文本的颜色...


如何获取 SwiftUI Color 的浅色或深色模式版本?

如何在 SwiftUI 中创建一个专门包含暗模式颜色的局部变量。 我试图避免将每个视图的配色方案指定为深色以获得深色模式颜色。 例如在


如何使带有链接的按钮看起来像普通按钮?

我有一个按钮可以下载带有文件名的文件。为此,我写了这样的内容: 我有一个按钮可以下载带有文件名的文件。为此,我写了这个: <Button color='primary' href=`/apiproxy/objects/${id}/subobjects` LinkComponent={React.forwardRef((props, ref) => <Link {...props} type='text/csv' download={`object_${id}_subobjects.csv`} ref={ref} />)} /> 生成的按钮看起来与其他没有 href 属性的按钮相同(也带有 color='primary'),但悬停时其文本颜色变为蓝色,与其他按钮不同,它保持白色。 如何使其样式与其他按钮相同?我可以将 &:hover 文本颜色指定为白色,但是当主题更改其他按钮的文本颜色时,这会中断。 有没有办法更改链接组件,使其样式与其他按钮相同,或者如果没有,按钮在调色板中使用什么作为悬停文本颜色,以便我可以将其设置为该颜色? 我认为你可以在 Link 组件中使用 sx 属性。就像下面... <Button color="primary" href="/apiproxy/objects/1/subobjects" LinkComponent={React.forwardRef((props, ref) => ( <Link {...props} type="text/csv" download={"object_1_subobjects.csv"} ref={ref} sx={{ "&:hover": { color: "white", }, }} /> ))} />


在React-Icons中添加原始颜色图标

这是我的代码片段: 社会行动('github')} /> < 这是我的代码片段: <div className="mt-6 flex gap-2"> <AuthSocialButton icon={BsGithub} onClick={() => socialAction('github')} /> <AuthSocialButton icon={BsGoogle} onClick={() => socialAction('google')} /> </div> React-icons 本身只有空白灰色。有没有办法将徽标颜色添加到反应图标中?我不是说添加背景颜色,我的意思是例如Google图标必须有Google等的图标颜色 感谢您的宝贵时间。 您是否尝试添加内联样式或 CSS 类? 类似的东西? <AuthSocialButton icon={<BsGithub style={{ color: '#333' }} />} // GitHub's color onClick={() => socialAction('github')}/>


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> 这意味着我们将拥有卡片视图并将整个布局放入其中......


仅在页面底部添加边距

我有一个始终固定在视图底部的 cookie 部分。 啦啦啦啦 我有一个始终固定在视图底部的 cookie 部分。 <section id="cookie-section"> <span id="cookie-text">Bla bla bla</span> </section> #cookie-section { min-height: 50px; width: 100%; position: fixed; display: flex; bottom: 0; background-color: rgba(38, 38, 38, 0.9); } 但是当你滚动并到达页面底部时,我想为其添加 50px 的 margin-bottom 。我该怎么做? 当你只是添加 margin-bottom: 50px; 到它时,它已经在开始时获得了我不想要的边距。仅当您滚动到达页面底部时。 可以使用滚动驱动动画,但支持还不好。 您可以使用 Google Chrome 测试以下内容 #cookie-section { min-height: 50px; inset: auto 0 0; position: fixed; display: flex; background-color: rgba(38, 38, 38, 0.9); color: #fff; animation: margin 2s; animation-timeline: scroll(root) } @keyframes margin { 0%,90% {margin-bottom:0;} 100% {margin-bottom:50px;} } body { min-height: 300vh; } <section id="cookie-section"> <span id="cookie-text">Bla bla bla</span> </section>


如何让 MUI 的带有链接的按钮看起来像普通按钮?

我有一个按钮可以下载带有文件名的文件。为此,我写了这样的内容: 我有一个按钮可以下载带有文件名的文件。为此,我写了这个: <Button color='primary' href=`/apiproxy/objects/${id}/subobjects` LinkComponent={React.forwardRef((props, ref) => <Link {...props} type='text/csv' download={`object_${id}_subobjects.csv`} ref={ref} />)} /> 生成的元素看起来与我的其他没有 href 属性的按钮相同(也带有 color='primary'),但悬停时其文本颜色更改为蓝色,与其他按钮不同,它保持白色。 如何使其样式与其他按钮相同?我可以将 &:hover 文本颜色指定为白色,但是当主题更改其他按钮的文本颜色时,这会中断。 有没有办法更改链接组件,使其样式与其他按钮相同,或者如果没有,按钮在调色板中使用什么作为悬停文本颜色,以便我可以将其设置为该颜色? 我认为您可以使用 styledComponent 作为链接组件。就像下面... const theme = useTheme(); const StyledLink = styled(Link)(({ theme, color = "primary" }) => ({ ":hover": { color: theme.palette.secondary.main, }, })); <Button color="primary" href="/apiproxy/objects/1/subobjects" LinkComponent={React.forwardRef((props, ref) => ( <StyledLink {...props} type="text/csv" download={"object_1_subobjects.csv"} ref={ref} theme={theme} /> ))} /> 您可以在 theme.js 文件中的调色板中设置悬停颜色,并使用该颜色,如 theme.palette.${hoverColor} 请检查此测试组件。 https://codesandbox.io/p/sandbox/mui-28251-28335-forked-j2x8cd?file=%2Fsrc%2FApp.js 也许您可以让按钮将它们重定向到可以下载文件的 MediaFire: <a href="link-to-media"><button class="buttonClass">Download</button></a> 然后你可以将buttonClass修改为你喜欢的任何内容。


为什么 .className = .... 不起作用,而 classList.add() 却起作用?

.youtube-文本{ 字体系列:Arial; 字体大小:更大; } .订阅按钮{ 字体系列...</desc> <question vote="0"> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; .youtube-text { font-family: Arial; font-size: larger; } .subscribe-button { font-family: &#39;Arial Narrow Bold&#39;; font-size: large; color: white; background-color: black; padding-left: 12px; padding-top: 12px ; padding-bottom: 12px ; padding-right: 12px; border-radius: 20px; } .is-subscribed { font-family: &#39;Arial Narrow Bold&#39;; font-size: large; color: black; background-color: white; padding-left: 12px; padding-top: 12px ; padding-bottom: 12px ; padding-right: 12px; border-radius: 20px; } &lt;/style&gt; &lt;title&gt; &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p2&gt;Youtube Subscribe Button&lt;/p2&gt;&lt;br&gt;&lt;Br&gt; &lt;button class = &#39;subscribe-button&#39; onclick=&#34; subscribeButton(); &#34;&gt;Subscribe&lt;/button&gt; &lt;script async&gt; function subscribeButton() { const subButton = document.querySelector(&#39;.subscribe-button&#39;); if (subButton.innerHTML === &#39;Subscribe&#39;){ subButton.innerHTML = &#39;Subscribed&#39;; subButton.classList.add(&#39;is-subscribed&#39;); } else { subButton.innerHTML = &#39;Subscribe&#39;; subButton.classList.remove(&#39;is-subscribed&#39;); } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; .youtube-text { font-family: Arial; font-size: larger; } .subscribe-button { font-family: &#39;Arial Narrow Bold&#39;; font-size: large; color: white; background-color: black; padding-left: 12px; padding-top: 12px ; padding-bottom: 12px ; padding-right: 12px; border-radius: 20px; } .is-subscribed { font-family: &#39;Arial Narrow Bold&#39;; font-size: large; color: black; background-color: white; padding-left: 12px; padding-top: 12px ; padding-bottom: 12px ; padding-right: 12px; border-radius: 20px; } &lt;/style&gt; &lt;title&gt; &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p2&gt;Youtube Subscribe Button&lt;/p2&gt;&lt;br&gt;&lt;Br&gt; &lt;button class = &#39;subscribe-button&#39; onclick=&#34; subscribeButton(); &#34;&gt;Subscribe&lt;/button&gt; &lt;script async&gt; function subscribeButton() { const subButton = document.querySelector(&#39;.subscribe-button&#39;); if (subButton.innerHTML === &#39;Subscribe&#39;){ subButton.innerHTML = &#39;Subscribed&#39;; subButton.className = &#39;is-subscribed&#39;; } else { subButton.innerHTML = &#39;Subscribe&#39;; subButton.className = &#39;subscribe-button&#39;; } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>你好, 我刚刚开始使用 JS,想知道我遇到的这个问题。顶部的代码有效,底部的代码无效,第一次单击时,它确实将类更改为已订阅,但是当我按下按钮,它给出了一个错误,并且不再改变它,我只是想知道为什么会这样。</p> </question> <answer tick="false" vote="0"> <p>默认的 DOM elemnt 对象没有名为 <pre><code>className</code></pre> 的属性。将 classList 属性与 <pre><code>.add()</code></pre> 和 <pre><code>.remove()</code></pre> 方法结合使用。</p> </answer> <answer tick="false" vote="0"> <blockquote> <p>但是当我按下按钮时,它给出了一个错误并且不再改变它</p> </blockquote> <p>当您按下按钮时,代码会按类查找元素:</p> <pre><code>const subButton = document.querySelector(&#39;.subscribe-button&#39;); </code></pre> <p>但是该类没有这样的元素。当您设置 <em><code>className</code></em> 时,您<pre>删除了</pre>该类:</p> <pre><code>subButton.className = &#39;is-subscribed&#39;; </code></pre> <p>这<em>用</em><code>class</code><pre>替换了</pre>整个<pre><code>is-subscribed</code></pre>,而不是<em>添加</em>到类列表中。</p> </answer> </body></html>


如何防止我的CSS规则被reactjs/jsx中的规范化CSS覆盖?

我有一个非常简单的反应组件 类 UpgradeContainer 扩展组件 { 使成为() { 返回 ( 我有一个非常简单的反应组件 class UpgradeContainer extends Component { render() { return ( <div className={styles.msg}> <div className={styles['msg-container']}> <h3 className={`${styles.title} highlight-color`}> Big Header </h3> <div className={`${styles.description} alternate-color`}> Small text <br /> Some more small text </div> </div> </div> ); } 这是相关的css .title { font-size: 40px; line-height: 50px; color: white; } .description { text-align: center; font-size: 16px; padding: 20px 0 10px; color: white; } 这是上面组件的 DOM 输出 此处以文本形式转载: <div class="mRMOZryRtlFUx_NHlt1WD" data-reactid=".0.1.0.0.0.1"> <h3 class="_2s6iXRZlq-nQwIsDADWnwU highlight-color" data-reactid=".0.1.0.0.0.1.0"> Big Header</h3> <div class="_1pFak-xR0a8YH6UtvoeloF alternate-color" data-reactid=".0.1.0.0.0.1.1"> <span data-reactid=".0.1.0.0.0.1.1.0">Small text</span> <br data-reactid=".0.1.0.0.0.1.1.1"> <span data-reactid=".0.1.0.0.0.1.1.2">Some more small text</span></div></div> 如你所见,reactjs 添加了几个 <span/> 来包裹小文本 我希望标题文本 (Big Header) 比描述文本(small text 和 some more small text)大得多。 输出看起来像这样: 这是因为reactjs出于某种原因添加了一个span来包裹文本small text和some more small text(data-reactid“.0.1.0.0.0.1.1.0”和“.0.1.0.0.0.1.1.2”分别) 当我检查样式时,我发现这些 span 元素的样式被以下 css 规则覆盖 我真的很困惑,因为这些规则不是我自己定义的。 所以我点击 <style>...</style>,它会将我带到 我想知道如何有效地覆盖这些CSS规则? 我想要的最终结果是: 如果您使用“Normalize.css”! 此问题的解决方案是将主 css 文件“style.css”保留在底部。至少低于normalize.css。 如果您使用 Bootstrap, 直接来自 Bootstrap 官方网站,“为了改进跨浏览器渲染,我们使用 Normalize.css,这是 Nicolas Gallagher 和 Jonathan Neal 的一个项目。” 这个问题的解决方案是将主 css 文件“style.css”保留在底部。至少低于 bootstrap.css。 我遇到了与您类似的问题,我的解决方案是在 app.tsx 文件顶部导入 Bootstrap 样式。这样做的原因是它可以防止 Bootstrap CSS 被应用程序中的其他样式覆盖,它对我有用


在仪表针中设置弹出框(Echarts)

我有这段代码,我尝试将鼠标悬停在第一个仪表针上以获取 .popover({...}) 对象: </sc...</desc> <question vote="0"> <p>我有这段代码,我尝试将鼠标悬停在第一个仪表针上以获取 .popover({...}) 对象:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code> &lt;head&gt; &lt;script src=&#34;https://code.jquery.com/jquery-3.6.4.min.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://cdnjs.cloudflare.com/ajax/libs/echarts/5.3.0/echarts.min.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css&#34;&gt; &lt;title&gt;Gauge Chart&lt;/title&gt; &lt;/head&gt; &lt;button id=&#39;btn1&#39;&gt; Let&#39;s &lt;/button&gt; &lt;input id=&#39;slider1&#39; type=&#39;range&#39; value=&#39;34&#39; min=&#39;0&#39; max=&#39;100&#39; step=&#39;.01&#39;&gt; &lt;input id=&#39;slider2&#39; type=&#39;range&#39; value=&#39;89&#39; min=&#39;0&#39; max=&#39;100&#39; step=&#39;.01&#39;&gt; &lt;div id=&#39;chartid1&#39; style=&#39;width:390px; height: 410px;&#39;&gt;&lt;/div&gt; &lt;script&gt; const chart1 = echarts.init(document.getElementById(&#39;chartid1&#39;)); function update1(value1, value2) { option = { series: [{ type: &#39;gauge&#39;, min: 0, max: 100, splitNumber: 10, detail: { fontFamily: &#39;Lato&#39;, fontSize: 14, borderWidth: 1, borderColor: &#39;#020202&#39;, borderRadius: 5, width: 32, height: 20 }, data: [{ value: value1, name: &#39;False&#39;, itemStyle: { color: &#39;#dd4b50&#39; }, title: { offsetCenter: [&#39;-20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;-20%&#39;, &#39;36%&#39;], backgroundColor: &#39;#dd4b50&#39;, color: &#39;#f2f2f2&#39; } }, { value: value2, name: &#39;True&#39;, itemStyle: { color: &#39;#3a9e4b&#39; }, title: { offsetCenter: [&#39;20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;20%&#39;, &#39;36%&#39;], color: &#39;#f2f2f2&#39;, backgroundColor: &#39;#3a9e4b&#39; } } ] }] }; chart1.setOption(option); } function update2() { let value1 = Number($(&#39;#slider1&#39;).val()); let value2 = Number($(&#34;#slider2&#34;).val()); update1(value1, value2); } update2(); document.getElementById(&#39;btn1&#39;).addEventListener(&#39;click&#39;, function() { update2(); }) /// clickable chart1.on(&#39;mouseenter&#39;, {dataIndex:0}, function(params) { $(this).popover({ html: true, sanitize: false, title: &#39;Title &#39;, content: &#39;This a text&#39;, trigger: &#39;hover&#39;, placement: &#39;top&#39;, container: &#39;body&#39; }) }) &lt;/script&gt;</code></pre> </div> </div> <p></p> <p>我需要悬停并获得 .popover。我知道我可以使用 <pre><code>tooltip:{...}</code></pre>,但对于特定情况,我需要配置 .popover。我尝试用 <pre><code>mychart1.on(...</code></pre> 调整上面的代码,但没有成功。我添加了所有代码需求的CDN。</p> </question> <answer tick="false" vote="0"> <p>如果您查看 <a href="https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseover" rel="nofollow noreferrer">文档</a>,该事件称为 <pre><code>mouseover</code></pre>,而不是 <pre><code>mouseenter</code></pre>。 <a href="https://echarts.apache.org/examples/en/editor.html?c=line-simple&code=PYBwLglsB2AEC8sDeAoWsDOBTAThLGAXLANprrLkWxgCeIWxA5AOYCGAri1kwDRUUAthGjEADP2rpBbAB7EAjGIkD0GEABsIYAHIdBAI1yKVU2ABMsYNhA3FUZ9ADMYYAGJthG2swAybMGA-VQoXaDAAZQgAL0ZYBQAWSUcDYBxLHAB1CHMwAAtFZLNU9NwAYWANNOYAYjEAJgaG4MdYEoyAJTZzCA4iWABWIqkAdxz84gBmeuHqPKwIFjywYkaQgF9ZiwC2YjJWh1bYADc2DQ44yaSQ6mhPOKYPDWwWo-0sQQi6DTjDo9gAMaVaqwJg1czmBIGAZiJg3CibeHoSBgH72JEUYBOJzYMBlLDhYykJgAWkaAFI-KCKUwALoYxH_SzWWzo_7oLE4qz4wk4Pakmm8UGTABslNpW2KbABAGsWDhgBxoOYKlU-aDwZDobDJVIgWrak56kajXD_ut4YzHH9HKdznEABwATl16DuggeABUcBdXq13p9vr8Meh9SCwZM2E6sFCzUcra0UWjKOzYJzcTywESSExBdSxOKGa6LFYbHYU-z09yCVn1Tm80xReLi6HgeqwSbjfU_UcDNK5QqlSq27VI9HYwzLSF6dQLeh6esANwoFeCWhlPJsHBgAB0MAAFExBIrsMBjrgqUhzDsAJLKrDyWBiTawJxKgGQA8gLeeDAASgrIFoAwSosB3KoWH3b8cF_P9l3WOCgA" rel="nofollow noreferrer">这里</a>是你的例子:</p> <pre><code>option = { series: [ { type: &#39;gauge&#39;, min: 0, max: 100, splitNumber: 10, detail: { fontFamily: &#39;Lato&#39;, fontSize: 14, borderWidth: 1, borderColor: &#39;#020202&#39;, borderRadius: 5, width: 32, height: 20 }, data: [ { value: 34, name: &#39;False&#39;, itemStyle: { color: &#39;#dd4b50&#39; }, title: { offsetCenter: [&#39;-20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;-20%&#39;, &#39;36%&#39;], backgroundColor: &#39;#dd4b50&#39;, color: &#39;#f2f2f2&#39; } }, { value: 89, name: &#39;True&#39;, itemStyle: { color: &#39;#3a9e4b&#39; }, title: { offsetCenter: [&#39;20%&#39;, &#39;20%&#39;] }, detail: { offsetCenter: [&#39;20%&#39;, &#39;36%&#39;], color: &#39;#f2f2f2&#39;, backgroundColor: &#39;#3a9e4b&#39; } } ] } ] }; myChart.on(&#39;mouseover&#39;, {dataIndex: 0}, function(params) { console.log(params); }); </code></pre> </answer> </body></html>


Vue.js 风格的 v-html 和范围内的 css

如何使用 vue-loader 使用范围内的 css 设置 v-html 内容的样式? 简单的例子: 组件.vue 如何使用 vue-loader 使用范围内的 css 设置 v-html 内容的样式? 简单的例子: 组件.vue <template> <div class="icon" v-html="icon"></icon> </template> <script> export default { data () { return {icon: '<svg>...</svg>'} } } </script> <style scoped> .icon svg { fill: red; } </style> 生成html <div data-v-9b8ff292="" class="icon"><svg>...</svg></div> 生成CSS .info svg[data-v-9b8ff292] { fill: red; } 如您所见,v-html 内容没有 data-v 属性,但生成的 css 对于 svg 具有 data-v 属性。 我知道这是 vue-loader 的预期行为(https://github.com/vuejs/vue-loader/issues/359)。在本期中提到了后代选择器。但正如你所看到的,我在我的 css 中使用了它,但它不起作用。 如何设置 v-html 内容的样式? 我正在使用vue-loader 15.9.1。 >>>解决方案对我不起作用(没有效果),而/deep/方法导致构建错误...... 这是有效的: .foo ::v-deep .bar { color: red; } 正如我在这里的回答所述: 新版本的vue-loader(从版本12.2.0开始)允许您使用“深层范围”CSS。你需要这样使用它: <style scoped>现在支持可以影响子级的“深度”选择器 使用 >>> 组合器的组件: .foo >>> .bar { color: red; } 将被编译为: .foo[data-v-xxxxxxx] .bar { color: red; } 更多信息请参见vue-loader的发布页面 将 /deep/ 选择器与 SCSS 一起使用对我来说不起作用,但后来我尝试使用 ::v-deep 选择器 例如 ::v-deep a { color: red; } 参见这个答案 AS Sarumanatee 说,如果接受的答案不起作用,请尝试: .foo /deep/ .bar { color: red; } 使用:deep {} 根据您的情况,您应该这样做: <template> <div class="icon" v-html="icon"></div> </template> <style scoped> .icon { :deep { svg { fill: red; } } } </style>


获取不可编辑、灰色但内容可选的输入元素

我有 和 元素,其内容在某些步骤中不应可编辑。 因此,最初我向这些元素添加了一个禁用属性。元素</desc> <question vote="0"> <p>我有 <pre><code><input type="text"></code></pre> 和 <pre><code><textarea></code></pre> 元素,其内容在某些步骤中不应可编辑。</p> <p>所以,最初我为这些元素添加了 <pre><code>disabled</code></pre> 属性。这些元素变得不可编辑并且呈灰色。这个行为很好。</p> <p>但是,它们的内容应该是可选择的,而 <pre><code>disabled</code></pre> 属性避免了这种情况。所以我切换到了 <pre><code>readonly</code></pre> 属性。元素仍然不可编辑,内容可以选择,但不再是灰色的。</p> <p>因此,我正在寻找一种解决方案来包含以下元素:不可编辑、可选择和灰显。</p> <ul> <li>我可以应用一些 CSS,但我更喜欢禁用输入的本机浏览器样式。</li> <li>这些元素不是<pre><code><form></code></pre>的一部分,因此无需担心表单提交。</li> </ul> </question> <answer tick="false" vote="0"> <p>要在不使用disabled属性的情况下实现具有不可编辑、可选择和灰显元素的所需行为,您可以使用CSS和readonly属性的组合。您可以设置只读元素的样式,使其看起来像已禁用,同时保留选择其内容的能力。以下是如何实现此目标的示例:</p> <pre><code>input[readonly], textarea[readonly] { color: #777; /* Set text color to a muted color */ background-color: #eee; /* Set background color to a light grey */ cursor: not-allowed; /* Show a not-allowed cursor to indicate non editable state */ } /* Adjust the style for textareas, if needed */ textarea[readonly] { resize: none; /* Disable textarea resizing */ } </code></pre> <pre><code><!-- Your HTML elements with readonly attribute --> <input type="text" readonly> <textarea readonly></textarea> </code></pre> </answer> </body></html>


如何以 Svelte 方式设置导出和开槽零件的样式?

Svelte slot 的功能是否像 vanilla-js/dom 一样(我似乎无法让它工作)。 在 html/js 中我可以这样做: 身体{颜色:红色;} /* 从外部设置暴露部分的样式 */ ...</desc> <question vote="0"> <p>Svelte <pre><code>slot</code></pre>的功能是否像 vanilla-js/dom 一样(我似乎无法让它工作)。</p> <p>在 html/js 中我可以做:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code>&lt;style&gt; body {color: red;} /* style exposed part from outside */ my-element::part(header) {color: green;} &lt;/style&gt; &lt;h1&gt;Hello World&lt;/h1&gt; &lt;my-element&gt; &lt;div slot=&#34;header&#34;&gt;&lt;strong&gt;Header&lt;/strong&gt;&lt;/div&gt; &lt;div slot=&#34;body&#34;&gt;Body&lt;/div&gt; &lt;/my-element&gt; &lt;script&gt; customElements.define(&#39;my-element&#39;, class extends HTMLElement { constructor() { super(); const shadowRoot = this.attachShadow({mode: &#39;open&#39;}); shadowRoot.innerHTML = ` &lt;style&gt; .container { border: solid 1px blue; padding: 5px; position: relative; &amp;:after { content: &#34;my-element&#34;; display: block; position: absolute; bottom: -.5em; right: 5px; border: inherit; background-color: white; padding: inherit; } } /* style inserted/slotted part from inside */ [part=&#34;body&#34;] ::slotted(div) { background-color: lightyellow; } &lt;/style&gt; &lt;div class=&#34;container&#34;&gt; &lt;header part=&#34;header&#34;&gt;&lt;slot name=&#34;header&#34;&gt;&lt;/slot&gt;&lt;/header&gt; &lt;hr&gt; &lt;div part=&#34;body&#34;&gt;&lt;slot name=&#34;body&#34;&gt;&lt;/slot&gt;&lt;/div&gt; &lt;/div&gt; `; } }); &lt;/script&gt;</code></pre> </div> </div> <p></p> <p>其中 <pre><code>h1</code></pre> 的全局样式为红色,标有 <pre><code>part=&#34;header&#34;</code></pre> 的元素从外部设置为绿色,插入 <pre><code>slot=&#34;body&#34;</code></pre> 的内容从内部(shadow dom)设置为绿色有浅黄色背景。</p> <p>我不知道如何在 svelte 中执行任何这种(受控)跨界样式? (例如,当使用 <pre><code>AppShell::part(content)</code></pre> 时,我收到错误:</p> <pre><code>[plugin:vite-plugin-svelte] C:/srv/svelte/yoda5/src/routes/+layout.svelte:23:18 Expected a valid CSS identifier C:/srv/svelte/yoda5/src/routes/+layout.svelte:23:18 21 | 22 | &lt;style&gt; 23 | AppShell::part(content) { | ^ </code></pre> </question> <answer tick="false" vote="0"> <p>这里有关于<a href="https://learn.svelte.dev/tutorial/slots" rel="nofollow noreferrer">老虎机的课程</a>。最好参考该工具的文档。 Svelte 的学习网站非常棒。</p> <pre><code>// Slotted component, say Test.svelte. &lt;div class=&#34;private-parent&#34;&gt; &lt;slot /&gt; &lt;/div&gt; &lt;style&gt; div.private-parent { color: blue; } &lt;/style&gt; </code></pre> <p>然后,您使用该组件:</p> <pre><code>&lt;script&gt; import Test from &#39;./Test.svelte&#39;; &lt;/script&gt; &lt;Test&gt; &lt;!-- This is the slot&#39;s content --&gt; &lt;p class=&#34;outside-style&#34;&gt;Hello!&lt;/p&gt; &lt;/Test&gt; &lt;style&gt; p.outside-style { color: darkred; } &lt;/style&gt; </code></pre> </answer> </body></html>


在这个curl api中将不记名授权令牌放在哪里

我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: 我正在使用 imageqrcode (https://imageqrcode.com/apidocumentation) 的新 api 功能来动态生成图像 QR 码,使用 php: <?php $api_key = 'xxxxxxxxxx'; //secret // instantiate data values $data = array( 'apikey' => $api_key, 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', ); // connect to api $url = 'https://app.imageqrcode.com/api/create/url'; $ch = curl_init($url); // Attach image file $imageFilePath = 'test1.jpg'; $imageFile = new CURLFile($imageFilePath, 'image/jpeg', 'file'); $data['file'] = $imageFile; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); // Handle the response $result = json_decode($response, true); if ($result && isset($result['downloadURL'])) { // Successful request $download_url = $result['downloadURL']; echo "Download URL: $download_url"; } else { // Handle errors echo "Error: " . print_r($result, true); } ?> 在文档中显示有变量“serialkey”: 图片二维码API文档 API文档 生效日期:2023年11月15日 图像二维码 API 是一项接受 HTTPS 请求以生成图像或 gif 二维码的服务,主要由开发人员使用。 图像二维码 - URL JSON 请求(POST):https://app.imageqrcode.com/api/create/url apikey //你的apikey 序列号//你的序列号 qrtype //字符串,最少 2 个字符,最多 2 个字符v1 或 v2,v1 适用于 QR 类型 1,v2 适用于类型 2 color //数字,最小 6 位,最大 6 位,例如000000 为黑色 text //url,最少 15 个字符,最多 80 个字符https://yourwebsite.com file //图像文件 (jpg/jpeg/png),最大 1 MB 文件大小 现在没有信息将该序列密钥作为标准承载授权令牌放在哪里???如果没有此信息,我无法连接到 api 我尝试在没有不记名令牌的情况下连接它,因为我认为它可以匿名连接到 api,但也不起作用,我现在很困惑,因为我仍在学习 PHP 和 Laravel 看起来 serialkey 不是不记名令牌,而是一个应该与其他参数(如 apikey、qrtype、color、text 和 )一起包含在 POST 数据中的参数file。您可以在 PHP 代码的 serialkey 数组中包含 $data。 $data = array( 'apikey' => $api_key, 'serialkey' => 'your_serial_key', // Add this line 'qrtype' => 'v1', 'color' => '000000', 'text' => 'https://wikipedia.com', );


如何在React Prime DataTable中添加超链接?

我有一个数据表,我正在使用 React prime 库, 我的要求是在一个特定列中添加一个链接。 我有一个数据表,我正在使用 React prime 库, 我的要求是在一个特定列中添加一个链接。 <DataTable paginator rows={tableRowPage} value={products} tableStyle={{ minWidth: "30rem" }} ><Column key={field} field={field} header={header} style={{ width: "25%" }} /> </DataTable> 我需要特定单元格中的超链接 我在数据表中遇到了同样的问题,不幸的是,根据我的研究,他们似乎不提供对此的支持。 但是,我已经设法通过这种方式解决了这个问题: 数据表添加链接逻辑: <Column field="code" header="Code" body={(rowData) => { return ( <div sx={{ display: "flex", justifyContent: "space-between", alignItems: "center", }} > <div style={{ color: "#3F00FF", textDecoration: "underline", cursor: "pointer", "&:hover": { color: "#23297A", }, }} onClick={() => window.open("www.google.com", "_blank").focus()} > {rowData.code} </div> </div> ); }} ></Column>; 我已经使用 Prime React Column 组件中的 body 渲染了数据。我应用 CSS 将其设置为链接样式,并添加了 onClick 事件以进行重定向。您可以根据您的要求修改逻辑。 完整代码链接:https://codesandbox.io/s/primereact-demo-forked-kqtdvs?file=/src/App.jsx 如果您还有任何疑问,请告诉我。


为什么我的全景切换按钮不起作用?

我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户观看 360 度全景图时,按钮不应旋转。 我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户查看 360 度全景图时,按钮不应旋转。 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>panoramas</title> <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> <style> #switchButton { cursor: pointer; } </style> </head> <body> <a-scene> <a-assets> <img id="panorama1" src="1.jpg"> <img id="panorama2" src="2.jpg"> </a-assets> <a-sky id="panorama" src="#panorama1" rotation="0 -130 0"></a-sky> <a-entity id="cameraRig"> <a-camera></a-camera> </a-entity> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#CCC" id="switchButton"></a-plane> </a-scene> <script> const button = document.querySelector('#switchButton'); let currentPanorama = 1; button.addEventListener('mouseenter', () => { const panorama = document.querySelector('#panorama'); if (currentPanorama === 1) { panorama.setAttribute('src', '#panorama2'); currentPanorama = 2; } else { panorama.setAttribute('src', '#panorama1'); currentPanorama = 1; } }); </script> </body> </html> 我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户查看 360 度全景图时,按钮不应旋转。 我解决你的问题 您需要做的是添加一个光标来处理 onlcick 事件,这是唯一的方法。 <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width"> <title>A-Frame HTML Shader - Dynamic</title> <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script> <script src="https://unpkg.com/[email protected]/dist/aframe-html-shader.min.js"></script> <script> let currentPanorama = 1; AFRAME.registerComponent("click-log", { init: function () { this.myFunction = function () { const panorama = document.querySelector('#panorama'); if (currentPanorama === 1) { panorama.setAttribute('src', '#panorama2'); currentPanorama = 2; } else { panorama.setAttribute('src', '#panorama1'); currentPanorama = 1; } }; this.el.addEventListener("click", this.myFunction); }, remove: function () { this.el.removeEventListener("click", this.myFunction); } }); </script> </head> <body> <a-scene update-html> <a-camera> <a-cursor material="color: red"></a-cursor> </a-camera> <a-assets> <img id="panorama1" src="https://l13.alamy.com/360/PWNBM9/testing-new-cameralens-combination-in-my-garden-in-aarhus-denmark-PWNBM9.jpg"> <img id="panorama2" src="https://aframe.io/aframe/examples/boilerplate/panorama/puydesancy.jpg"> </a-assets> <a-sky id="panorama" src="#panorama1" rotation="0 -130 0"></a-sky> <a-entity id="cameraRig"> <a-camera></a-camera> </a-entity> <a-plane click-log position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#CCC" id="switchButton"></a-plane> </a-scene> </body> </html>


完整日历:使用 IF 语句为事件着色

我有一个基于站点管理员打开的票证的日历。我们有四种类型的门票: 待办的 进行中 完成的 取消 这是我有日历的 div: 我有一个基于站点管理员打开的票证的日历。我们有四种类型的门票: 待定 进行中 完成了 取消 这是我有日历的div: <div class="col-lg-6 col-md-10 col-sm-11"> <div class="card"> <div class="card-header" data-background-color="blue"> <h4 class="title">Calendario</h4> </div> <br> <section class="content"> <?php $events = TicketData::getEvents(); foreach($events as $event){ $thejson[] = array("title"=>$event->title,"url"=>"./?view=editticket&id=".$event->id,"start"=>$event->date_at."T".$event->time_at); } // print_r(json_encode($thejson)); ?> <script> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next, today', center: 'title', right: 'month,agendaWeek,agendaDay' }, defaultDate: jQuery.now(), editable: false, eventLimit: true, // allow "more" link when too many events events: <?php echo json_encode($thejson); ?> }); }); </script> <div class="row"> <div class="col-md-12"> <div id="calendar"> </div> </div> </div> </section> </div> </div> 门票的数据库结构很简单:id、title、description、date_at、time_at、created_at、tecnico_id和status_id。 我想使用 if 脚本“着色”事件: 这是我的代码,但它不起作用。 <section class="content"> <?php $events = TicketData::getEvents(); // $status->status_id; foreach($events as $event){ $thejson[] = array("title"=>$event->title,"url"=>"./?view=editticket&id=".$event->id,"start"=>$event->date_at."T".$event->time_at,); $thejsonColor[] = array($event->status_id); } // print_r(json_encode($thejson)); ?> <script> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next, today', center: 'title', right: 'month,agendaWeek,agendaDay' }, defaultDate: jQuery.now(), editable: false, eventLimit: true, // allow "more" link when too many events events: <?php echo json_encode($thejson); ?>, if ($thejsonColor=1){ eventColor: 'fb8c00' }else if ($thejsonColor=2){ eventColor: 'ff0' } else if ($thejsonColor=3){ eventColor: '43a047' } else { eventColor: '00acc1' } }); }); </script> 我想让它们符合颜色标准,这样用户就可以知道哪些票是待处理的、不完整的、完整的和已取消的。 我是 javascript 的新手,我不知道如何做到这一点。你们能帮助我或指出我应该如何做吗? 您可以在迭代事件数组时设置颜色: <?php // helper function to pick the right color function getColor($id) { $eventColor = ''; if ($id == 1) { $eventColor = '#fb8c00'; } else if ($id == 2) { $eventColor = '#ff0'; } else if ($id == 3) { $eventColor = '#43a047'; } else { $eventColor = '#00acc1'; } return $eventColor; } $events = TicketData::getEvents(); //pulls the events from TicketData.php foreach($events as $event) { $thejson[] = array( "title" => $event->title, "url" => "./?view=editticket&id=".$event->id, "start" => $event->date_at."T".$event->time_at, "color" => getColor($event->status_id)); } ?> 然后就像你现在正在做的那样回显事件: <script> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next, today', center: 'title', right: 'month,agendaWeek,agendaDay' }, defaultDate: jQuery.now(), editable: false, eventLimit: true, // allow "more" link when too many events events: <?php echo json_encode($thejson); ?>, }); }); </script> 或者您可以通过从 php 中的表中选择来完成此操作,例如: $sql = "SELECT CASE WHEN tickets='Pending'" THEN '#C6E0B4' WHEN tickets='In progres' THEN '#FFFF99' END AS color" $schedules = $conn->query($sql); $sched_res = []; foreach($schedules->fetch_all(MYSQLI_ASSOC) as $row){ $sched_res[$row['id']] = $row; } 然后就像你现在正在做的那样回显事件: <script> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next, today', center: 'title', right: 'month,agendaWeek,agendaDay' }, defaultDate: jQuery.now(), editable: false, eventLimit: true, // allow "more" link when too many events events: <?php echo json_encode($thejson); ?>, }); }); </script>


有什么问题吗?文本区域什么也没显示,但值是

我正在编写代码以在 中以灰色向用户显示提示; 接下来的想法是: 最初以灰色显示“请在此处输入您的询问”; 如果用户点击它,颜色会变为...</desc> <question vote="3"> <p>我正在编写代码以在 <pre><code><textarea/></code></pre> 中以灰色向用户显示提示;</p> <p>下一个想法是:</p> <ol> <li>最初将<pre><code>'Please, type your inquiry there'</code></pre>置于灰色;</li> <li>如果用户单击它,颜色将变为黑色,文本将变为 <pre><code>''</code></pre>。这部分工作正常;</li> <li>如果用户输入然后删除(即将字段留空),那么我们需要将 <pre><code>'Please, type your inquiry there'</code></pre> 放回灰色。</li> </ol> <p>步骤 (3) 在 Chrome 和 Firefox 中均不起作用。它什么也没显示。当我使用 Chrome 检查器时,它显示:</p> <blockquote> <p>element.style { 颜色: rgb(141, 141, 141); }</p> </blockquote> <p>这是正确的,而 HTML 中的 <pre><code>"Please, type your inquiry there"</code></pre> 也是正确的。但场地是空的。可能是什么问题??? 我特别使用了 <pre><code>console.log()</code></pre>,它们还显示应该是......的输出 </p>这是 HTML 和 JS 代码:<p> </p><code><textarea name='contact_text' id='contact_text' onclick='text_area_text_cl();' onBlur='text_area_text_fill();'> </textarea> <script> var contact_text_changed = false; var contact_contacts_changed = false; function text_area_text() { if (contact_text_changed == false) { $("#contact_text").css("color","#8d8d8d"); $("#contact_text").html('Please, type your inquiry there'); } else { $("#contact_text").css("color","#000000"); } // Write your code here }; function text_area_text_cl() { if (contact_text_changed == false) { $("#contact_text").text(''); $("#contact_text").css("color","#000000"); console.log('sdfdfs111'); contact_text_changed = true; } }; function text_area_text_fill() { if ($("#contact_text").val() == '') { contact_text_changed = false; $("#contact_text").css("color","#8d8d8d"); $("#contact_text").html('Please, type your inquiry there'); //document.getElementById('contact_text').innerHTML = 'Please, type your inquiry there' console.log('sdfdfs'); } else { console.log('__'); } }; // call functions to fill text_area_text(); </script> </code><pre> </pre> </question> <answer tick="true" vote="3">要设置 <p><code><textarea></code><pre> 的值,您需要使用 </pre><code>.val()</code><pre>:</pre> </p><code>$("#contact_text").val(''); </code><pre> </pre>或<p> </p><code>$("#contact_text").val('Please, type your enquiry there'); </code><pre> </pre>等等。让“占位符”代码正常工作是很棘手的。 <p>较新的浏览器允许<a href="http://caniuse.com/#search=placeholder" rel="nofollow">:</a> </p><code><textarea placeholder='Please, type your enquiry there' id='whatever'></textarea> </code><pre> </pre>他们会为您管理这一切。<p> </p><p>编辑<em> - 从评论中,这里解释了为什么 </em><code>.html()</code><pre> 最初有效(嗯,它</pre>确实<em>有效,但请继续阅读)。 </em><code><textarea></code><pre> 元素的标记内容(即元素中包含的 DOM 结构)表示 </pre><code><textarea></code><em> 的 </em>initial<pre> 值。在任何用户交互之前(和/或在 JavaScript 触及 DOM 的“value”属性之前),这就是显示为字段值的内容。然后,更改 DOM 的该部分就会更改该初始值。然而,一旦进行了一些用户交互,初始值就不再与页面视图相关,因此不会显示。仅显示更新后的值。</pre> </p> </answer></body>


在React语义ui列表元素中显示奇怪的字符而不是项目符号点

我正在使用react语义ui列表项目符号,但部署后项目符号点显示像奇怪的字符。我已经在 index.html 文件中包含以下代码 我正在使用 React 语义 ui 列表项目符号,但部署后项目符号点显示像奇怪的字符。我已经在index.html文件中包含了以下代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <meta name="theme-color" content="#000000" /> 我也有这个问题,为什么它们只是偶尔出现,并且不可选,也不属于html?


iPhone 移动视图上的 ReactJS 状态栏为黑色

我查找了解决方案,大多数都是关于 PWA 的,但这是一个静态网页。 我尝试添加到我的index.html 文件中,但仍然没有任何内容。在 Safari 和 Chrome 上同样如此 我查找了解决方案,大多数都是关于 PWA 的,但这是一个静态网页。 我尝试添加到我的index.html 文件中,但仍然没有任何结果。 Safari 和 Chrome 上同样 <meta name='viewport' content='initial-scale=1, viewport-fit=cover'> 这就是我想要实现的目标 我希望黑条的颜色和网页一样 要更改颜色,请更改 index.html 中的代码 <meta name="theme-color" content="#0d436d" /> 根据您需要的颜色修改内容。


单击 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希望这个解决方案可以帮助你:)


如何使用 Bootstrap 5 禁用自定义范围而不更改样式?

我有范围: 我有范围: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> </head> <body> <div class="container mb-4 col-sm-5"> <input type="range" class="custom-range" min="0" max="10" value="10" id="range-input" style="width: 100%"> </div> </body> </html> 我想禁用它(它应该仍然看起来一样,但用户不能再与它交互),但是不改变样式。例如: 图中,顶部的启用,底部的禁用;我想禁用它,同时保持顶级范围的样式。 我尝试手动重新创建原始样式,但没有成功: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> <style> input[type=range]:disabled { background-color: blue; color: blue; background: blue; } </style> </head> <body> <div class="container mb-4 col-sm-5"> <input type="range" class="custom-range" min="0" max="10" value="10" id="range-input" style="width: 100%" disabled> </div> </body> </html> 除此之外,我在研究中找不到任何其他可能的解决方案。 您实际上需要“如何”禁用它? 设置 pointer-events: none 并添加 tabindex="-1",你会得到一个看起来仍然相同的元素,但用户无法再与之交互(至少通过鼠标单击/点击,并且他们无法通过键盘将其聚焦)控制其中之一 - 不确定是否还有其他什么?) 由于没有设置 name 属性,该字段不会成为表单提交数据集的一部分 - 如果在您的实际用例中有所不同,您也可以删除(并重新设置)名称,当您可以打开和关闭 tabindex。


标签错误:渲染时出现 React JSX 样式标签错误

这是我的反应渲染函数 渲染:函数(){ 返回 ( 某事 .rr{ 红色; ...</desc> <question vote="94"> <p>这是我的反应渲染函数</p> <pre><code>render:function(){ return ( &lt;div&gt; &lt;p className=&#34;rr&#34;&gt;something&lt;/p&gt; &lt;style&gt; .rr{ color:red; } &lt;/style&gt; &lt;/div&gt; ) } </code></pre> <p>这给了我这个错误</p> <blockquote> <p>JSX:错误:解析错误:第 22 行:意外的标记:</p> </blockquote> <p>这里出了什么问题? 我可以将完整的普通 CSS 嵌入到 React 组件中吗?</p> </question> <answer tick="false" vote="130"> <p>使用 es6 模板字符串(允许换行)很容易做到。在你的渲染方法中:</p> <pre><code>const css = ` .my-element { background-color: #f00; } ` return ( &lt;div className=&#34;my-element&#34;&gt; &lt;style&gt;{css}&lt;/style&gt; some content &lt;/div&gt; ) </code></pre> <p>至于用例,我正在为一个 div 执行此操作,其中包含一些用于调试的复选框,我希望将其包含在一个文件中,以便稍后轻松删除。</p> </answer> <answer tick="true" vote="73"> <p>JSX 只是 javascript 的一个小扩展,它不是自己完整的模板语言。所以你会像在 javascript 中那样做:</p> <pre><code>return ( &lt;div&gt; &lt;p className=&#34;rr&#34;&gt;something&lt;/p&gt; &lt;style&gt;{&#34;\ .rr{\ color:red;\ }\ &#34;}&lt;/style&gt; &lt;/div&gt; ) </code></pre> <p><a href="http://jsfiddle.net/r6rqz068/" rel="noreferrer">http://jsfiddle.net/r6rqz068/</a></p> <p>但是根本没有充分的理由这样做。</p> </answer> <answer tick="false" vote="30"> <p>内联样式最好直接应用于组件 JSX 模板:</p> <pre><code>return ( &lt;div&gt; &lt;p style={{color: &#34;red&#34;}}&gt;something&lt;/p&gt; &lt;/div&gt; ); </code></pre> <p>演示:<a href="http://jsfiddle.net/chantastic/69z2wepo/329/" rel="noreferrer">http://jsfiddle.net/chantastic/69z2wepo/329/</a></p> <hr/> <p><strong>注意:JSX 不支持 style 属性的 HTML 语法</strong></p> <p>使用驼峰式属性名称声明属性,例如,</p> <pre><code>{ color: &#34;red&#34;, backgroundColor: &#34;white&#34; } </code></pre> <p>进一步阅读此处:<a href="http://facebook.github.io/react/tips/inline-styles.html" rel="noreferrer">http://facebook.github.io/react/tips/inline-styles.html</a></p> </answer> <answer tick="false" vote="20"> <p>这可以通过使用反引号“`”来完成,如下所示</p> <pre><code>return (&lt;div&gt; &lt;p className=&#34;rr&#34;&gt;something&lt;/p&gt; &lt;style&gt;{` .rr{ color:red; } `}&lt;/style&gt; &lt;/div&gt;) </code></pre> </answer> <answer tick="false" vote="10"> <p>“class”是 JavaScript 中的保留字。而是使用“className”。</p> <p>此外,您必须记住您使用的是 JSX,而不是 HTML。我不相信 jsx 会解析你的标签。更好的方法是使用您的样式创建一个对象,然后将其应用为样式(见下文)。</p> <pre><code>var styles = { color:&#34;red&#34;; } return ( &lt;div&gt; &lt;p style={styles}&gt;something&lt;/p&gt; &lt;/div&gt; ) </code></pre> </answer> <answer tick="false" vote="8"> <ol> <li>创建一个函数来处理插入样式标签。</li> <li>将所需的 CSS 添加到字符串变量中。</li> <li><p>将变量添加到 <pre><code>&lt;style&gt;</code></pre> 标记内返回的 JSX。</p> <pre><code>renderPaypalButtonStyle() { let styleCode = &#34;#braintree-paypal-button { margin: 0 auto; }&#34; return ( &lt;style&gt;{ styleCode }&lt;/style&gt; ) } </code></pre></li> </ol> </answer> <answer tick="false" vote="4"> <p>这就是我所做的:</p> <pre><code>render(){ var styleTagStringContent = &#34;.rr {&#34;+ &#34;color:red&#34;+ &#34;}&#34;; return ( &lt;style type=&#34;text/css&#34;&gt; {styleTagStringContent} &lt;/style&gt; ); </code></pre> </answer> <answer tick="false" vote="0"> <p>经过一番摸索和尝试,终于找到了解决方案。 关键是危险的SetInnerHTML。 代码如下:</p> <pre><code> &lt;script src=&#34;https://pie-meister.github.io/PieMeister-with Progress.min.js&#34;&gt;&lt;/script&gt; import React from &#39;react&#39; const style = ` &lt;pie-chart class=&#34;nested&#34; offset=&#34;top&#34;&gt; &lt;style&gt; path { stroke-linecap: round; stroke-width: 90; } [color1] { stroke: #BFBDB2; stroke-width: 50; } [color2] { stroke: #26BDD8; stroke-width: 60; } [color3] { stroke: #824BF1; } [part=&#34;path&#34;]:not([y]) { stroke: #BFBDB2; stroke-width: 60; opacity: 0.4; } &lt;/style&gt; &lt;slice color1 size=&#34;100%&#34; radius=&#34;200&#34;&gt;&lt;!--No label--&gt;&lt;/slice&gt; &lt;slice color1 size=&#34;88%&#34; radius=&#34;200&#34; y=&#34;65&#34;&gt;&lt;tspan&gt; $size&lt;/tspan&gt;&lt;/slice&gt; &lt;slice color2 size=&#34;100%&#34; radius=&#34;100&#34;&gt; &lt;/slice&gt; &lt;slice color2 size=&#34;40%&#34; radius=&#34;100&#34; y=&#34;165&#34;&gt;&lt;tspan&gt; $size&lt;/tspan&gt;&lt;/slice&gt; &lt;slice color3 size=&#34;100%&#34; radius=&#34;0&#34;&gt; &lt;/slice&gt; &lt;slice color3 size=&#34;10%&#34; radius=&#34;0&#34; y=&#34;265&#34;&gt;&lt;tspan&gt; $size&lt;/tspan&gt;&lt;/slice&gt; &lt;/pie-chart&gt;` export default function Styles() { return ( &lt;div dangerouslySetInnerHTML={{__html:style}}/&gt; ) } </code></pre> </answer> <answer tick="false" vote="-3"> <pre><code>import styled from &#39;styled-components; return ( &lt;div&gt; &lt;Test&gt;something&lt;/Test&gt; &lt;/div&gt; ) </code></pre> <p>下一步:</p> <pre><code>const Test = styled.p` color: red `; </code></pre> </answer> </body></html>


这个标题如何粘贴?

这是我的 ant-list-header elemet css 这是我的 ant-list-header elemet css <div class="ant-list-header" style=" position: sticky; top: 0; z-index: 100; height: 30px; "><div class="sc-eDZJSx kXYedM"><strong>Unmapped Rate Plans</strong><strong>See all</strong></div></div> 这是我的 ant-list-items 元素 <ul class="ant-list-items"></ul> 什么样的CSS会让我粘上ant-list-header 现在 尝试过的位置:粘性但没有工作 .ant-list-header { position: sticky; top: 0; z-index: 100; height: 30px; background-color: white; } <div class="ant-list-header"> <div><strong>Unmapped Rate Plans</strong><strong>See all</strong></div> </div> <ul class="ant-list-items"> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> <li>some text</li> </ul>


填充区域显示的隐藏内容溢出,可以隐藏吗?

div{内边距:5px;溢出:隐藏;高度:20px} 某事某事某事某事某事某事 <style> div{padding:5px;overflow:hidden;height:20px} </style> <div class="container"> something something something something something something something something something something something something something something <div> 小提琴:https://jsfiddle.net/v21vgzfc/ 在CSS中是否可以使文本也隐藏在填充区域中而不添加另一层? 是的,我会使用边框而不是填充。像这样: div{ border:solid 5px #00f; overflow:hidden; height:20px } 我想请给div一个宽度 <style> div{padding:5px;overflow:hidden;height:40px; width:250px; background:#009} </style> 您可以通过使用边框而不是填充来解决此问题。 div { border: 5px solid blue; overflow: hidden; background-color: blue; height: 40px } 看看它是如何在 this Fiddle 中工作的。 U 应该在父元素内创建一个嵌套元素,并将 overflow: hidden 应用于该嵌套元素。 <div class="parent"> <div class="child"> <!-- Content here --> </div> </div> .parent { padding: 20px; overflow: hidden; } .child { overflow: hidden; }


更改垫输入的波纹颜色

我现在一直在努力了解如何手动更改元素的波纹颜色,但我似乎无法让它以任何方式工作。 我现在一直在努力研究如何手动更改 <mat-input> 元素的波纹颜色,但我似乎无法让它以任何方式工作。 <input matInput type="number" (keydown)="updateManualPage(1)" placeholder="Filter" formControlName="filterParam1"> 我已经尝试了CSS中我能想到的一切,.mat-form-field-underline,.mat-form-field-ripple,包括我使用::after和::before选择器从另一个SO问题/答案中无耻地撕掉的一大块类,尝试使用 ::ng-deep、!important,但似乎没有任何东西可以改变从 @import "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css"; 导入的蓝色波纹的颜色 编辑:只需更好地阅读 API,所以我发现波纹后出现的边框颜色来自 <mat-form-field> 元素,该元素有一个颜色选择器。但是,该颜色选择器只能具有“primary”、“accent”和“warn”值。所以现在我想知道如何插入自定义颜色。 设法弄清楚了,原来如此 ::ng-deep .mdc-text-field--filled:not(.mdc-text-field--disabled) .mdc-line-ripple::after { border-bottom-color: *X* !important; }


如何使整个跨度落入新行?

这个片段显示了我想要的: http://jsfiddle.net/945Df/3/ 阿根廷圣达菲罗萨里奥。 这个片段显示了我想要的: http://jsfiddle.net/945Df/3/ <div class="sup" id="pr"> <strong> <a href="#">Rosario, Santa Fe, Argentina.</a> <span class="date">17 de septiembre de 2013.</span></strong> </div> <div class="sup"> <strong> <a href="#">Rosario, Santa Fe, Argentina.</a> <span class="date">17 de septiembre de 2013.</span> </strong> </div> 当div的宽度(在项目中,视口)没有更多空间时,我希望跨度落入新行。 抱歉我的解释不好。我不知道该怎么做。谢谢! 编辑:在第二个示例中,短语“SEPTIEMBRE DE 2013”。落入新行。但“17 DE”字样仍位于上行。我想要“2013 年 9 月 17 日”。落入新行。明白了吗? 如果您希望跨度不换行,而是完全移动到其他文本下方,您可以使用 white-space: nowrap; .date { text-transform: uppercase; color:#848484; white-space:nowrap; } 演示 要让span在空间不足时跳到下一行,可以设置为display: inline-block; .date { display: inline-block; ... } 检查这个:http://jsfiddle.net/945Df/7/ 这就是我实现它的方法: #spantomovedown{ clear: both; display: inline-block; width: 100%; } .date{display:inline-block;} 当日期比div长时,换行显示 示例:http://jsfiddle.net/TqRyK/ 如果你漂浮:对;当不再有空间容纳整个内容时,它应该落到下一行。 之后您将需要一个清除元件。 我通过以下方式实现了它 word-wrap: break word;


何时切换搜索栏和徽标下降?

.navbar { 背景颜色:#F91F46; } .src-bar { 边框:0; 边框半径:5px; 概要:无; 左内边距:15px; 宽度:30vw; } .navbar { background-color: #F91F46; } .src-bar { border: 0; border-radius: 5px; outline: none; padding-left: 15px; width: 30vw; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js" integrity="sha512-WW8/jxkELe2CAiE4LvQfwm1rajOS8PHasCCx+knHG0gBHt8EXxS6T6tJRTGuDQVnluuAvMxWF4j8SNFDKceLFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <nav class="navbar navbar-expand-md fixed-top"> <div class="container-fluid"> <a class="navbar-brand ms-3" href="#"> <img src="img/Logo.avif" width="40px" class="d-inline-block" /> </a> <form role="search" class="search-bar"> <div class="input-group"> <input class="src-bar" type="search" placeholder="Search For Products" /> <button class="btn bg-white" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> <div class="justify-content-end"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav-colps" aria-controls="nav-colps" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="nav-colps"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> <hr class="dropdown-divider" /> </li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </div> </nav> 切换时,我希望折叠 div 居中。我知道原因 - 我将折叠和切换 btn 放在 justify-end div 内,因为我需要切换 btn 位置位于右侧。现在,当切换时,我的折叠位于右侧,但我希望在切换时,折叠div到中心。 当我删除 justify-end div 时,它位于左侧,但如果删除它,每个导航元素都会移动到 nav 和 md 视图中 lg 的左侧。 看起来像这样或中心 我们确实需要将 .nav-collapse 移到 justify-end 元素之外,才能在较窄的视口上获得所需的布局。 要将菜单显示在右侧,请通过 flex-grow: 1 类将 .nav-collapse 应用于 flex-grow: 0 元素,覆盖 flex-grow-0 上的默认 .nav-collapse。 为了使窄视口的链接元素居中,.navbar-nav中的元素采用垂直柔性布局,因此我们可以通过align-items: center类应用align-items-center: .navbar { background-color: #F91F46; } .src-bar { border: 0; border-radius: 5px; outline: none; padding-left: 15px; width: 30vw; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js" integrity="sha512-WW8/jxkELe2CAiE4LvQfwm1rajOS8PHasCCx+knHG0gBHt8EXxS6T6tJRTGuDQVnluuAvMxWF4j8SNFDKceLFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <nav class="navbar navbar-expand-md fixed-top"> <div class="container-fluid"> <a class="navbar-brand ms-3" href="#"> <img src="https://picsum.photos/40/40" width="40px" class="d-inline-block" /> </a> <form role="search" class="search-bar"> <div class="input-group"> <input class="src-bar" type="search" placeholder="Search For Products" /> <button class="btn bg-white" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav-colps" aria-controls="nav-colps" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse flex-grow-0" id="nav-colps"> <ul class="navbar-nav me-auto mb-2 mb-lg-0 align-items-center"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> <hr class="dropdown-divider" /> </li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </nav> 您还可以考虑通过 text-align: center 类应用 text-center,将链接元素 text 居中: .navbar { background-color: #F91F46; } .src-bar { border: 0; border-radius: 5px; outline: none; padding-left: 15px; width: 30vw; } <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js" integrity="sha512-WW8/jxkELe2CAiE4LvQfwm1rajOS8PHasCCx+knHG0gBHt8EXxS6T6tJRTGuDQVnluuAvMxWF4j8SNFDKceLFg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <nav class="navbar navbar-expand-md fixed-top"> <div class="container-fluid"> <a class="navbar-brand ms-3" href="#"> <img src="https://picsum.photos/40/40" width="40px" class="d-inline-block" /> </a> <form role="search" class="search-bar"> <div class="input-group"> <input class="src-bar" type="search" placeholder="Search For Products" /> <button class="btn bg-white" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#nav-colps" aria-controls="nav-colps" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse flex-grow-0" id="nav-colps"> <ul class="navbar-nav me-auto mb-2 mb-lg-0 text-center"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> <hr class="dropdown-divider" /> </li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> </div> </div> </nav>


.NET MAUI:自定义Shell TitleView并绑定到当前页面标题

我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: 我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: <?xml version="1.0" encoding="UTF-8" ?> <Shell x:Class="MyNamespace.App.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyNamespace.App" xmlns:pages="clr-namespace:MyNamespace.App.Pages" BindingContext="{x:Static local:MainView.Instance}" Shell.FlyoutBehavior="{Binding ShellFlyoutType}" x:Name="shellMain"> <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" Text="{Binding Path=CurrentPage.Title, Mode=OneWay}" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> <ShellContent Title=" Login" ContentTemplate="{DataTemplate local:MainPage}" Route="login" FlyoutItemIsVisible="False" /> <ShellContent Title="Dashboard" ContentTemplate="{DataTemplate pages:DashboardPage}" Route="dashboard" /> </Shell> 我无法绑定当前页面标题。 我的 AppShell.xaml Shell 声明如下 <Shell ... x:Name="shellMain"> 作为替代方案,您可以在 OnNaviged 方法中设置 titleview : 在 AppShell.xaml 中,定义标签的名称 <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" x:Name="mylabel" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> 在AppShell.xaml.cs中,重写OnNaviged方法,获取当前项目 protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); var shellItem = Shell.Current?.CurrentItem; string title = shellItem?.Title; int iterationCount = 0; while (shellItem != null && title == null) { title = shellItem.Title; shellItem = shellItem.CurrentItem; if (iterationCount > 10) break; // max nesting reached iterationCount++; } myLabel.Text = title; } 希望它对你有用。 我正在尝试同样的方法来修改 TitleView 的外观。它可以在 iOS 上运行,尽管那里还有另一个错误。但在 Android 上我遇到了同样的问题。在前进导航中,它会更新标题,但当您按后退按钮时,标题不会更新。我已经打开了一个问题并添加了一个存储库。 https://github.com/dotnet/maui/issues/12416#issuecomment-1372627514 还有其他方法可以修改TitleView的外观吗? 我使用视图模型开发了这个解决方法,主要不是为了提供 MVVM 解决方案,而是因为其他建议的答案对我不起作用。 (我怀疑 Liqun Shen 2 月 15 日针对他自己的问题的评论中的建议会起作用。但我没有注意到这一点,直到我自己修复)。 当前页面的标题保存在可由 shell 的视图模型和每个内容页面的视图模型访问的类中: public class ServiceHelper { private static ServiceHelper? _default; public static ServiceHelper Default => _default ??= new ServiceHelper(); internal string CurrentPageTitle { get; set; } = string.Empty; } shell 中每个内容页面的视图模型提供其页面标题。为了促进这一点,大部分工作都是由基本视图模型完成的,它们都是从该模型派生而来的: public abstract class ViewModelBase(string title) : ObservableObject { private ServiceHelper? _serviceHelper; public string Title { get; } = title; internal ServiceHelper ServiceHelper { get => _serviceHelper ??= ServiceHelper.Default; set => _serviceHelper = value; // For unit testing. } public virtual void OnAppearing() { ServiceHelper.CurrentPageTitle = Title; } } 每个 shell 内容页面视图模型只需要让其基础视图模型知道它的标题: public class LocationsViewModel : ViewModelBase { public LocationsViewModel() : base("Locations") { } } 每个 shell 内容页面都需要在其视图模型中触发所需的事件响应方法: public partial class LocationsPage : ContentPage { private LocationsViewModel? _viewModel; public LocationsPage() { InitializeComponent(); } private LocationsViewModel ViewModel => _viewModel ??= (LocationsViewModel)BindingContext; protected override void OnAppearing() { base.OnAppearing(); ViewModel.OnAppearing(); } } Shell 的视图模型为标题栏提供当前页面的标题: public class AppShellViewModel() : ViewModelBase(Global.ApplicationTitle) { private string _currentPageTitle = string.Empty; public string CurrentPageTitle { get => _currentPageTitle; set { _currentPageTitle = value; OnPropertyChanged(); } } public void OnNavigated() { CurrentPageTitle = ServiceHelper.CurrentPageTitle; } } Shell 需要在其视图模型中触发所需的事件响应方法: public partial class AppShell : Shell { private AppShellViewModel? _viewModel; public AppShell() { InitializeComponent(); } private AppShellViewModel ViewModel => _viewModel ??= (AppShellViewModel)BindingContext; protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); ViewModel.OnNavigated(); } } 最后,Shell 的 XAML 在标题栏/导航栏上显示由 Shell 视图模型提供的当前页面的标题: <Shell.TitleView> <HorizontalStackLayout VerticalOptions="Fill"> <Image Source="falcon_svg_repo_com.png" HeightRequest="50"/> <Label x:Name="CurrentPageTitleLabel" Text="{Binding CurrentPageTitle}" FontSize="24" Margin="10,0" VerticalTextAlignment="Center"/> </HorizontalStackLayout> </Shell.TitleView>


SVG 可以有多小?

我刚刚缩小了这个SVG: 我刚刚缩小了这个 SVG: <?xml version="1.0" standalone="no"?> <svg viewBox="0 0 480 150" style="background-color:#ffffff00" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" x="0px" y="0px" width="480" height="150"> <path d="M 0 35.5 L 6.5 22.5 L 16 37 L 23 24 L 34.8 43.7 L 42.5 30 L 50.3 47 L 59.7 27.7 L 69 47 L 85 17.7 L 98.3 39 L 113 9.7 L 127.7 42.3 L 136.3 23.7 L 147 44.3 L 158.3 20.3 L 170.3 40.3 L 177.7 25.7 L 189.7 43 L 199.7 21 L 207.7 35 L 219 11 L 233 37 L 240.3 23.7 L 251 43 L 263 18.3 L 272.7 33.3 L 283 10 L 295 32.3 L 301.3 23 L 311.7 37 L 323.7 7.7 L 339.3 39 L 346.3 25.7 L 356.3 42.3 L 369.7 15 L 376.3 25.7 L 384 9 L 393 28.3 L 400.3 19 L 411.7 38.3 L 421 21 L 434.3 43 L 445 25 L 453 36.3 L 464.3 18.3 L 476.2 40.3 L 480 33.5 L 480 215 L 0 215 L 0 35.5 Z" fill="#175720"/> </svg> 对此: <svg height="150" width="480"><path d="m0 35.5l6.5-13 9.5 14.5 7-13 11.8 19.7 7.7-13.7 7.8 17 9.4-19.3 9.3 19.3 16-29.3 13.3 21.3 14.7-29.3 14.7 32.6 8.6-18.6 10.7 20.6 11.3-24 12 20 7.4-14.6 12 17.3 10-22 8 14 11.3-24 14 26 7.3-13.3 10.7 19.3 12-24.7 9.7 15 10.3-23.3 12 22.3 6.3-9.3 10.4 14 12-29.3 15.6 31.3 7-13.3 10 16.6 13.4-27.3 6.6 10.7 7.7-16.7 9 19.3 7.3-9.3 11.4 19.3 9.3-17.3 13.3 22 10.7-18 8 11.3 11.3-18 11.9 22 3.8-6.8v181.5h-480v-179.5z" fill="#175720"/></svg> (我通过最小化程序运行它,然后删除了 <svg> 标签中的一堆属性。)我将它用作背景图像,它似乎在 Windows 上的 IE、Firefox 和 Chrome 中工作正常。我只是想知道如果其他信息对图像外观没有影响的话,它在那里做什么。因为我删除了该信息,会在某个地方出现兼容性问题吗? 更新: 我发现实际上,对于我的用例,我需要有 xmlns="http://www.w3.org/2000/svg",否则它不会在 IE 或 Chrome 中呈现。 删除 viewBox 会产生显着的语义差异,因为 SVG 将不再缩放(即响应 UA 调整大小)。这仅适用于您直接查看图像的情况,但如果您将其作为背景图像查看或通过 SVG <image> 标签或 html <img> 标签查看,则 SVG 将被绘制为好像它具有 viewBox 为“0 0 宽度高度”,除非 viewBox 已经存在。 删除 background-color 将意味着 SVG 当放置在其他东西之上时将不再是不透明的。当然,如果你不这样做,你可能不会注意到。 仅当 SVG 文件中有文本元素时,xml:space 属性才重要。 如果 SVG 是内联的,其余的删除都是良性的。如果 SVG 是独立文件,则需要命名空间属性,但背景图像就是这种情况。 简化版本不是有效的 SVG。它将被视为“任何”恰好具有名称为“svg”的根元素的 XML。 要将片段转换为 the SVG,只有一个选项: 将具有正确命名空间的 xmlns 属性添加到 svg 元素(正如您所发现的) 不再建议在文档中添加 DOCTYPE,并且从 Chrome 53 起就不起作用。将文档作为 MIME 类型 image/svg+xml 提供服务也不够。 示例: <svg xmlns="http://www.w3.org/2000/svg">(消费者选择的SVG版本) <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">(适用于 SVG 1.0) 使用W3验证器检查您的文件。请务必检查检测到的文档类型是否为 SVG,因为该文档可能仍然有效,但作为一般/未知的 XML。 -- 他们还有测试页面。


我如何根据状态更改按钮颜色(绿色表示“接受”,红色表示“删除”)

如何根据状态更改按钮颜色(绿色表示“接受”,红色表示“删除”) 我是新人,为此使用 Laravel 框架。 这是我的观点 如何根据状态更改按钮颜色(绿色表示“接受”,红色表示“删除”) 我是新人,为此使用 Laravel 框架。 这是我的看法 <table class="table table-striped" id="example"> <thead> <tr> <th>ID no</th> <th>Form Name</th> <th style="text-align: center">Update</th> <th>Delete</th> <th>Status</th> </tr> </thead> @foreach($form as $show) {{--modal--}} <div class="modal fade mj_popupdesign mj_checkoutpopup" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-body"> <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-2"> <div class="row"> <div class="mj_pricingtable mj_greentable mj_login_form_wrapper"> <form> <div class="mj_login_form"> <p>Are you sure you want to delete this post?</p> <br> <a href="" class="mj_btn btn btn-default pull-right glyphicon glyphicon-remove "> No</a> <a href="{{url('deleteForm',$show->id)}}" class=" pull-right mj_btn btn btn-danger glyphicon glyphicon-ok"> Yes</a> </div> </form> </div> </div> </div> </div> </div> </div> </div> {{--end modal--}} <tbody> <tr> <td> <p> {{$show->id}}</p> </td> <td> <h6><a href="{{url('JobDetails',$show->id)}}"style="color: rgb(0, 191, 243);font-size:18px;float: left;margin: 0;text-align: left">{{$show->jobTitle}}</a> </h6> <p> {{$show->created_at}} </p> </td> <td> <a href="{{url('UpdateFormView',$show->id)}}"> <span class="mj_btn btn btn-success">Update</span> </a> </td> <td> <span class="mj_btn btn btn-danger" data-toggle="modal" data-target="#myModal2">Delete</span> </td> <td><span class="mj_btn btn btn-warning">pending</span> </td> </tr> </tbody> @endforeach </table> </div> </div> </div> </div> 在我的控制器中public function AcquiredForm() { $acquired="Requirement Form"; $acquireForm=Job::where('jobType','LIKE','%'.$acquired.'%'); $form = $acquireForm->get(); return view('private-pages.company.aquire-form',compact('form')); } 数据库状态默认为待处理 数据库状态默认为pending 我在代码中没有看到 status 属性,但显示状态为待处理的纯字符串 <span class="mj_btn btn btn-warning">pending</span> <!-- while it suppose to be --> <span class="mj_btn btn btn-warning">{{ $show->status }}</span> 假设它确实存在,你可以做 <td> @if ($show->status === 'Accept') <span class="mj_btn btn btn-green">Accepted</span> @elseif ($show->status === 'Delete') <span class="mj_btn btn btn-danger">Deleted</span> @else <span class="mj_btn btn btn-warning">Pending</span> @endif </td> 参见:https://laravel.com/docs/5.1/blade#displaying-data <td> @if ($show->jobstatus === "Accepted") <span class="mj_btn btn btn-success">Accepted</span> @elseif ($show->jobstatus === "Rejected") <span class="mj_btn btn btn-danger">Rejected</span> @else <span class="mj_btn btn btn-warning">Pending</span> @endif </td> 或者当你使用 1. laravel esialy customaize this code nad add automatic refresh in the page to more interactive @php if($da->status == "requested") { echo "<td><button class='btn btn-primary'>Requested</button></td>"; } else { echo "<td><button class='btn btn-success'>Ordered</button></td>"; } @endphp


显示输入类型日期的占位符文本

占位符不适用于直接输入类型日期和日期时间本地。 占位符不适用于直接输入类型 date 和 datetime-local。 <input type="date" placeholder="Date" /> <input type="datetime-local" placeholder="Date" /> 该字段在桌面上显示 mm/dd/yyy,而在移动设备上则不显示任何内容。 如何显示 Date 占位符文本? 使用onfocus="(this.type='date')",例如: <input required="" type="text" class="form-control" placeholder="Date" onfocus="(this.type='date')"/> 使用onfocus和onblur...这是一个例子: <input type="text" placeholder="Birth Date" onfocus="(this.type='date')" onblur="if(this.value==''){this.type='text'}"> 在这里,我尝试了 data 元素中的 input 属性。并使用 CSS 应用所需的占位符 <input type="date" name="dob" data-placeholder="Date of birth" required aria-required="true" /> input[type="date"]::before { content: attr(data-placeholder); width: 100%; } /* hide our custom/fake placeholder text when in focus to show the default * 'mm/dd/yyyy' value and when valid to show the users' date of birth value. */ input[type="date"]:focus::before, input[type="date"]:valid::before { display: none } <input type="date" name="dob" data-placeholder="Date of birth" required aria-required="true" /> 希望这有帮助 <input type="text" placeholder="*To Date" onfocus="(this.type='date')" onblur="(this.type='text')" > 这段代码对我有用。只需使用这个即可 对于 Angular 2,你可以使用这个指令 import {Directive, ElementRef, HostListener} from '@angular/core'; @Directive({ selector: '[appDateClick]' }) export class DateClickDirective { @HostListener('focus') onMouseFocus() { this.el.nativeElement.type = 'date'; setTimeout(()=>{this.el.nativeElement.click()},2); } @HostListener('blur') onMouseBlur() { if(this.el.nativeElement.value == ""){ this.el.nativeElement.type = 'text'; } } constructor(private el:ElementRef) { } } 并像下面一样使用它。 <input appDateClick name="targetDate" placeholder="buton name" type="text"> 对于 React,你可以这样做。 const onDateFocus = (e) => (e.target.type = "datetime-local"); const onDateBlur = (e) => (e.target.type = "text"); . . . <input onFocus={onDateFocus} onBlur={onDateBlur} type="text" placeholder="Event Date" /> 我是这样做的: var dateInputs = document.querySelectorAll('input[type="date"]'); dateInputs.forEach(function(input) { input.addEventListener('change', function() { input.classList.add('no-placeholder') }); }); input[type="date"] { position: relative; } input[type="date"]:not(.has-value):before { position: absolute; left: 10px; top: 30%; color: gray; background: var(--primary-light); content: attr(placeholder); } .no-placeholder:before{ content:''!important; } <input type="date" name="my-date" id="my-date" placeholder="My Date"> 现代浏览器使用 Shadow DOM 来方便输入日期和日期时间。因此,除非浏览器出于某种原因选择回退到 text 输入,否则不会显示占位符文本。您可以使用以下逻辑来适应这两种情况: ::-webkit-calendar-picker-indicator { @apply hidden; /* hide native picker icon */ } input[type^='date']:not(:placeholder-shown) { @apply before:content-[attr(placeholder)]; @apply sm:after:content-[attr(placeholder)] sm:before:hidden; } input[type^='date']::after, input[type^='date']::before { @apply text-gray-500; } 我使用了 Tailwind CSS 语法,因为它很容易理解。让我们一点一点地分解它: ::-webkit-calendar-picker-indicator { @apply hidden; /* hide native picker icon */ } 使用其 Shadow DOM 伪元素选择器隐藏本机选择器图标(通常是日历)。 input[type^='date']:not(:placeholder-shown) { @apply before:content-[attr(placeholder)]; @apply sm:after:content-[attr(placeholder)] sm:before:hidden; } 选择所有未显示占位符的 date 和 datetime-local 输入,并且: 默认使用 placeholder 伪元素显示输入 ::before 文本 在小屏幕及以上屏幕上切换为使用 ::after 伪元素 input[type^='date']::after, input[type^='date']::before { @apply text-gray-500; } 设置 ::before 和 ::after 伪元素的样式。


“限制将街景标记添加到传单地图中的特定区域

我决定通过创建挪威夏季的公路旅行地图来开始学习 Leaflet 和 JavaScript,这是我的项目的可重复示例: 我决定通过创建挪威夏季的公路旅行地图来开始学习 Leaflet 和 JavaScript,这是我的项目的可重复示例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick-theme.css"/> <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js"></script> <link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.css" /> <script src="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.js"></script> <style> body { margin: 0; } #map { width: 100%; height: 100vh; } .carousel { max-width: 300px; margin: 10px auto; } .carousel img { width: 100%; height: auto; } /* Custom styling for Geiranger popup content */ .geiranger-popup-content { max-width: 500px; padding: 20px; } </style> </head> <body> <div id="map"></div> <script> var map = L.map('map').setView([61.9241, 6.7527], 6); var streetViewMarker = null; // Variable to keep track of the Street View marker L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); var roadTripCoordinates = [ [59.9139, 10.7522], // Oslo [62.2622, 10.7654], // Tynset [62.5949, 9.6926], // Oppdal [63.0071, 7.2058], // Atlantic Road [62.1040, 7.2054] // Geiranger ]; // Function to initialize Slick Carousel for a specific marker function initSlickCarousel(markerId, images) { $(`#${markerId}_carousel`).slick({ infinite: true, slidesToShow: 1, slidesToScroll: 1, dots: true, arrows: true }); // Add images to the carousel images.forEach(img => { $(`#${markerId}_carousel`).slick('slickAdd', `<div><img src="${img}" alt="Image"></div>`); }); } // Add markers for each destination with additional information and multiple pictures var destinations = [ { coordinates: [59.9139, 10.7522], name: 'Oslo', info: "../07/2023 : Start of the road-trip", images: ['https://www.ecologie.gouv.fr/sites/default/files/styles/standard/public/Oslo%2C%20Norvege_AdobeStock_221885853.jpeg?itok=13d8oQbU', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [62.2622, 10.7654], name: 'Tynset', info: "../07/2023 : Fly-fishing spot 1", images: ['https://www.czechnymph.com/data/web/gallery/fisheries/norway/glommahein/Kvennan_Fly_Fishing_20.jpg', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [62.5949, 9.6926], name: 'Oppdal', info: "../07/2023 : Awesome van spot for the night", images: ['https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSFRtpLlHWr8j6S2jNStnq6_Z9qBe0jWuFH8Q&usqp=CAU', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [63.0071, 7.2058], name: 'Atlantic Road', info: "../07/2023 : Fjord fishing", images: ['https://images.locationscout.net/2021/04/atlantic-ocean-road-norway.jpg?h=1100&q=83', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] }, { coordinates: [62.1040, 7.2054], name: 'Geiranger', info: "../07/2023 : Hiking 1", images: ['https://www.fjordtours.com/media/10968/nicola_montaldo-instagram-26th-may-2021-0717-utc.jpeg?anchor=center&mode=crop&width=1120&height=1120&rnd=133209254300000000&slimmage=True', 'https://via.placeholder.com/300', 'https://via.placeholder.com/300'] } ]; // Use Leaflet Routing Machine with Mapbox Routing plugin to get and display the route L.Routing.control({ waypoints: roadTripCoordinates.map(coord => L.latLng(coord[0], coord[1])), router: L.Routing.mapbox('MAP_BOX_KEY'), draggableWaypoints: false, addWaypoints: false, lineOptions: { styles: [{ color: 'brown', opacity: 0.7, weight: 2 }] } }).addTo(map); // Remove the leaflet-routing-container from the DOM var routingContainer = document.querySelector('.leaflet-routing-container'); if (routingContainer) { routingContainer.parentNode.removeChild(routingContainer); } destinations.forEach(function (destination) { var marker = L.marker(destination.coordinates).addTo(map); var markerId = destination.name.replace(' ', '_'); marker.bindPopup(` <b>${destination.name}</b><br> ${destination.info}<br> <div class="carousel" id="${markerId}_carousel"></div> `).on('popupopen', function () { // Initialize Slick Carousel when the marker popup is opened initSlickCarousel(markerId, destination.images); }).openPopup(); }); // Add Street View panorama on map click map.on('click', function (e) { if (streetViewMarker) { // Remove the existing Street View marker map.removeLayer(streetViewMarker); } let lat = e.latlng.lat.toPrecision(8); let lon = e.latlng.lng.toPrecision(8); streetViewMarker = L.marker([lat, lon]).addTo(map) .bindPopup(`<a href="http://maps.google.com/maps?q=&layer=c&cbll=${lat},${lon}&cbp=11,0,0,0,0" target="blank"><b> Cliquer ici pour avoir un aperçu de la zone ! </b></a>`).openPopup(); }); </script> </body> </html> 一切都按预期进行,我不得不说我对渲染非常满意。然而,通过查看 Stackoverflow 上的不同主题,我发现可以通过单击地图来显示 Google 街景视图。这个功能真的很酷,但我想限制仅在我的公路旅行行程中添加街景标记的选项。 有人可以帮我吗? 您通过创建挪威夏季公路旅行地图开始了学习 Leaflet 和 JavaScript 的旅程,真是太棒了。到目前为止,您的项目设置看起来不错,我很乐意在您的进展过程中提供指导或帮助。 既然您已经包含了 Leaflet、Slick Carousel 和 Leaflet Routing Machine 库,看来您正计划使用 Slick Carousel 创建一个带有路线的交互式地图,也许还有一些附加功能。 以下是一些增强您的项目的建议: 地图初始化: 使用初始视图和要显示的任何特定标记或图层设置您的传单地图。 路由功能: 利用 Leaflet Routing Machine 将动态路线添加到您的地图。您可以自定义路线、添加航点并提供逐向指示。 照片轮播: 既然您提到了公路旅行地图,请考虑集成 Slick Carousel 来展示旅途中关键地点的照片或描述。这可以为您的地图添加视觉上吸引人的元素。 地图控制: 探索 Leaflet 插件或内置控件以增强用户体验。例如,您可以添加缩放控件或比例尺。 响应式设计: 确保您的地图能够响应不同的设备。 Leaflet 通常适合移动设备,但如果需要的话进行测试和调整是一个很好的做法。 数据层: 如果您有与您的公路旅行相关的特定数据点或事件,您可以使用标记或其他视觉元素在地图上表示它们。 JavaScript 交互性: 使用 JavaScript 为地图添加交互性。对于 ㅤ 实例,当用户单击标记时,您可以创建包含附加信息的弹出窗口。 记得迭代测试你的项目,并参考每个库的文档以获取详细的使用说明。 如果您有具体问题或在此过程中遇到挑战,请随时提问。祝您的公路旅行地图项目好运!


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