我有一个典型的 HTML 结构,如下面的代码所示。
<div class="common-parent">
<div class="parent>
<div class="child">
<h2>Child 1</h2>
<span>Some text here...</span>
</div>
<div class="new-child">
<h2>New Child</h2>
<div>
<span>Some text here...</span>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在,我需要更改 div.parent 中所有元素的字体大小或 rem 大小,包括它自己。
由于默认的 rem 大小等于 16px,我需要将其减小到 12px,即 75%。我无法在 'html' 标签上更改它,因为它也会影响所有其他元素。
如何使用 SCSS 或 CSS 仅为“div.parent”和其中的所有元素更改它?
我需要创建一个正则表达式,无论字符串中的空格如何,该表达式都应查找最后的“ *”。然后,我需要用一些文本替换该字符串。
当前,它将替换字符串中首次出现的“ *”。
我如何解决它?
这是我的代码:
const regex = /\*/m;
const str = 'Field Name* * ';
const replaceStr = ' mandatory';
const result = str.replace(regex, replaceStr);
console.log('Substitution result: ', result);
Run Code Online (Sandbox Code Playgroud)
在此,输出应为“字段名称*必填”。但是我得到的是“必填字段名称*”。
I'm trying to write a method which will help me return an array of the object keys of all the currencies. But, I'm stuck at a point where I get the complete array of objects with key, value pair.
And yes, I primarily need to use ES6 methods. I wouldn't want to use any other iterators.
For e.g. : What I need:
['AED', 'ALL', 'AUD', 'EUR' .....]
Run Code Online (Sandbox Code Playgroud)
What I get :
[{AED: {"isDefault": true}}, {ALL: {"isDefault": true}}, {AUD: {"isDefault": true}}, …
Run Code Online (Sandbox Code Playgroud) 我编写了一个方法来计算数组中“启用”设置为“true”的对象数量。
每次在数组中找到“启用”设置为“真”的对象时,我都会添加 1 来进行计数。
在不使用“计数器”变量并使用减少或过滤的情况下如何实现这一目标?
这是我的代码:
function getCount() {
const arr =[[{ "enabled": true }], [{ "enabled": false}, {"enabled": true}]];
var count = 0;
arr.forEach(function(ar){
ar.forEach(function(obj){
if(obj.enabled) {
count++;
}
})
});
return count;
}
Run Code Online (Sandbox Code Playgroud) javascript reduce filter multidimensional-array ecmascript-6
我创建了一些虚拟的面包屑步骤。第一个面包屑步骤需要在左侧有一个正常的平面边框,这就完成了。在悬停时,我需要为每个面包屑项目显示黑色边框。
但唯一的问题是悬停时,对于第一个面包屑步骤,我没有按预期在左侧获得平坦的边框。
这是悬停时的预期:
这是我的代码:
body {
padding: 0;
margin: 0;
}
.breadcrumbs {
background-color: white;
width: 100%;
padding: 0 1rem;
font-size: 0;
margin: 1rem;
}
.breadcrumbs .breadcrumb-step {
display: inline-block;
width: 12.33%;
height: 5rem;
text-decoration: none;
color: black;
}
.step-title {
display: none;
}
.breadcrumb-step:before {
content: '';
display: block;
transform: skew(30deg);
border: 1px solid lightgrey;
border-bottom: none;
height: 50%;
width: 100%;
}
.breadcrumb-step:after {
content: '';
display: block;
transform: skew(-30deg);
border: 1px solid lightgrey;
border-top: none;
height: 50%;
width: …
Run Code Online (Sandbox Code Playgroud)