所以这里我有Bootstrap 4(以及flexbox)的问题.这是代码:HTML:
<section id="intro">
<div class="container-fluid">
<div class="row align-items-center">
<div class="col align-self-center">
<h1>We design things</h1>
</div>
</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
和CSS:
#intro {
min-height: 65vh;
background-image: url("../img/intro.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.container-fluid {
height: 100%;
min-height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
我希望.container-fluid始终是它的父高度的100%,所以如果section有100vh,容器也应该,如果它有50vh它也应该有50vh.我怎么做?如果它的高度是h1的高度,我无法使用flexbox居中.
所以我有一个带有表格的 Angular 8 应用程序,它显示已解析的 XML 内容,但在某些情况下,字符串可以包含
需要解析为 HTML 的标签,但也有其他内容用小于/大于符号支撑,例如. 我正在使用 [innerHTML] 将其注入标签,但这些带支撑的字符串被剪掉了。我试过像这样使用 DomSanitizer:
public sanitizeDsxText(text: any): any {
return this.sanitizer.bypassSecurityTrustHtml(text);
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,这也不起作用。有没有人遇到过类似的问题并且可以提供一个简单的解决方案?我将不胜感激:),
编辑:根据要求,更准确地说。我有一个这样的:
<td class="dsx-table__cell" [innerHTML]="item.target?.txt">
</td>
Run Code Online (Sandbox Code Playgroud)
“item.target?.txt”中的文本如下所示:
"Cze?? wam, tu bli?niaki dwa <br/> Paprika – siostra, brat <FAR/OFF>" *
并且<bt/>像它应该的那样解析到普通<br>标签,但<FAR/OFF>被删除 - 我需要找到一种方法来只解析<br>'s 并将其他字符串留在括号中而不解析。
所以我使用 CLI 制作了一个简单的 Angular 库ng g library <library-name>,并尝试从其模块导入组件。我正在导入数组中的应用程序模块中导入 Components.module ,但我希望能够将组件类从该模块导入到另一个组件,只需编写:
import {MyComponent} from ...;\nRun Code Online (Sandbox Code Playgroud)\n\n但我不能这样做 - 我的 IDE 说这个模块没有带有我的组件名称的导出成员,当我打开它时,它看起来像这样:
\n\nexport declare class ComponentsModule {\n}\nRun Code Online (Sandbox Code Playgroud)\n\n和 public_api.d.ts {
\n\nexport * from \'./lib/components.service\';\nexport * from \'./lib/components.component\';\nexport * from \'./lib/components.module\';\nRun Code Online (Sandbox Code Playgroud)\n\n另外,这是library-name.d.ts 文件:
\n\n/**\n* Generated bundle index. Do not edit.\n*/\nexport * from \'./public_api\';\nexport { ApiErrorComponent as \xc9\xb5a } from \'./lib/modals/api-error/api-error.component\';\nexport { ConfirmationModalComponent as \xc9\xb5b } from \'./lib/modals/confirmation- modal/confirmation-modal.component\';\nexport { InfoModalComponent as \xc9\xb5c } from \'./lib/modals/info-modal/info- …Run Code Online (Sandbox Code Playgroud) 所以我有一个简单的脚本,将"li"元素添加到"ul"并为它们分配一个类.现在我想在click事件上更改"li"项的类.
这是HTML:
<form class="form">
<input id="newInput" type="text" placeholder="Dodaj pozycj?">
<button id="createNew" type="button">Dodaj</button>
</form>
<h2>Moja lista:</h2>
<div class="listBg">
<ul id="list">
</ul>
</div>
<button id="deleteAll" type="button">Wyczy??</button>
Run Code Online (Sandbox Code Playgroud)
和JS:
function addItem() {
var myList = document.getElementById("list"); // get the main list ("ul")
var newListItem = document.createElement("li"); //create a new "li" element
var itemText = document.getElementById("newInput").value; //read the input value from #newInput
var listText = document.createTextNode(itemText); //create text node with calue from input
newListItem.appendChild(listText); //add text node to new "li" element
if (itemText === "") …Run Code Online (Sandbox Code Playgroud) 我有一个小型应用程序天气应用程序,它显示来自公共 API 的一些基本信息,并根据该信息向应用程序添加某个图标(例如太阳、多云)。用户可以在第一个之后检查另一个城市,我想在每次条件改变时更改该图标。我可以通过清除所有类,添加基本类,然后添加正确的图标类,或者只是将每个 if 更改为“classList(所有相关类),但我宁愿使用 RegEx 来做到这一点。这是应用程序的工作原理:
cityButton.addEventListener("click", function() {
if (mainIcon.classList.contains(new RegExp(/^wi-.+$/))) {
console.log("Icon contains wi-");
}
fetch(api + "q=" + cityInput.value + "&APPID=" + key + "&units=metric")
.then((resp) => resp.json())
.then((data) => {
let date = new Date();
let currentTime = date.getHours();
if (currentTime >= 6 && currentTime <= 18 && data.clouds.all < "25") {;
mainIcon.classList.add("wi-day-sunny");
} else if (currentTime >= 18 && currentTime <= 6 && data.clouds.all < "25") {
mainIcon.classList.add("wi-night-clear");
} else if (currentTime >= 6 …Run Code Online (Sandbox Code Playgroud) 我有一个简单的脚本,在单击按钮后将带有输入文本值的“li”元素添加到列表中,但我也想在单击按钮后清除此输入。这是 HTML:
<form class="form">
<input id="newInput" type="text" placeholder="Dodaj pozycj?">
<button id="createNew" type="button">Dodaj</button>
</form>
<h2>Moja lista:</h2>
<div class="listBg">
<ul id="list">
</ul>
</div>
<button id="deleteAll" type="button">Wyczy??</button>
Run Code Online (Sandbox Code Playgroud)
和JS:
function addItem(){
var myList = document.getElementById("list");
var newListItem = document.createElement("li");
var itemText = document.getElementById("newInput").value;
var listText = document.createTextNode(itemText);
newListItem.appendChild(listText);
if (itemText === "") {
alert("Pole nie mo?e by? puste");
} else {
myList.appendChild(newListItem);
}
};
function clearText(){
var itemText = document.getElementById("newInput").value;
itemText.innerText = "";
};
var addButton = document.getElementById("createNew");
addButton.addEventListener("click", function(){
addItem();
clearText();
});
function …Run Code Online (Sandbox Code Playgroud) html ×4
javascript ×4
angular ×2
css ×2
typescript ×2
angular-cli ×1
flexbox ×1
npm ×1
regex ×1