如何在 VSCode 编辑器的侧面选项卡上查看 HTML 代码实时预览?
我想要的最终结果:

CSS、js、PHP 等也应该可以在预览中使用。
我有一个用于我正在构建的仪表板的网格布局。我正在努力实现以下目标:
我很好奇是否有纯 CSS 方法来确保行保持完整,或者这是否需要 javascript。任何一个答案都足够了,但我更喜欢纯 css 解决方案。
到目前为止我的代码:
.grid-4-2-1 {
display: grid;
grid-template-areas: "grid-child-1 grid-child-2 grid-child-3 grid-child-4";
grid-template-columns: repeat(4, minmax(0, 1fr));
grid-gap: 20px;
margin: 20px;
}
.grid-child {
position: relative;
align-items: center;
justify-content: space-between;
padding-top: 100%;
background-color: #fff;
position: relative;
}
.grid-child .grid-content {
position: absolute;
right: 0px;
top: 0px;
height: 100%;
width: 100%;
}
@media only screen and (min-device-width: 768px) and (max-device-width: …Run Code Online (Sandbox Code Playgroud)我正在尝试从 componentWillReceiveProps 转移到 getDerivedStateFromProps ,在某些情况下,我成功了,但是当案例将道具附加到现有状态时,事情开始变得不一样了。当对组件的状态进行更新时,状态会发生变化(并且组件在更新后会发生变化)但仍呈现之前的状态。使用 getDerivedStateFromProp 而不是 componentWillReceiveProps 时会发生一些奇怪的事情。似乎该方法不能很好地处理“内部”更改。在以下示例中,我在 Child 上设置了 getDerivedStateFromProp 并且它可以工作,但因为仅渲染道具。在一个更简单的示例中也观察到了这种行为,其中我没有任何子组件并且只是呈现状态更改。
下面的代码显示了一个子组件,用于打印/显示 props 接收的数据,同时使用删除数据处理程序(从子组件交互中删除存储在父级的数据)。使用时getDerivedStateFromProps()I can't access tothis.state和 prevState 并不意味着相同,因为状态是累积的。当我从子组件中删除数据时,不会更新子组件的道具(使用 componentWillReceiveProps 没问题)。所以,我找不到替代我的方法UNSAFE_componentWillReceiveProps
componentWillReceiveProps:
UNSAFE_componentWillReceiveProps(nextProps){
this.setState({
data: [...this.state.data,...nextProps.data]
})
}
Run Code Online (Sandbox Code Playgroud)
getDerivedStateFromProps:
static getDerivedStateFromProps(nextProps,state) {
if (!isEqual(nextProps.data, state.data)) {
return {
data: [...state.data, ...nextProps.data]
};
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
按预期工作的原始代码(在 Parent Comp 上的 getDerivedStateFromProps 之前)
DataConsole - 父组件:
export class DataConsole extends Component {
// Used for unsubscribing when our components unmount
unsub = null; …Run Code Online (Sandbox Code Playgroud) 如何防止调整和最大化 Javascript 窗口?
我正在使用以下代码:
var win = window.open(myURL, "_blank", "toolbar=no,menubar=no,scrollbars=yes,dialog=yes,resizable=no,top=100,left=250,width=800,height=530");
Run Code Online (Sandbox Code Playgroud)
尝试了 Stackoverflow 的多种解决方案,但没有运气。有谁能够帮助我?
使用 Bootstrap 4,当table-responsive被添加到表格时,文本不再垂直居中。这是一个错误吗?如果没有,是否有一个简单的解决方案可以使文本居中居中。纯粹的 Bootstrap 解决方案将不胜感激。
这是问题的说明。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<table class="bg-danger table-responsive" style="width:300px; height:200px;">
<tr>
<th scope="row">
<div class="text-left">
table-responsive
</div>
</th>
</tr>
</table>
<table class="bg-success " style="width:300px; height:200px;">
<tr>
<th scope="row">
<div class="text-left">
no table-responsive
</div>
</th>
</tr>
</table>Run Code Online (Sandbox Code Playgroud)
我试图了解如何使用 css 为 3d 对象设置动画。现在我有一个等距类型的形状,当它悬停时会显示它的内部。但另外我想为这个等距形状设置动画以将 360 度旋转为 3d 形状无限。我一直在为每个盒子摆弄它的变换,但它根本不起作用。
任何人都可以帮助我并提供一些提示或解释我如何实现这一目标?
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.cube {
width: 100px;
height: 150px;
position: absolute;
background-color: red;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: 50% auto;
}
.outterstack .left {
min-width: 100px;
min-height: 250px;
transform-origin: 0 0;
transform: rotate(90deg) skewX(-30deg) scaleY(0.864);
background-color: grey;
}
.outterstack .right {
min-height: 100px;
min-width: 250px;
transform-origin: 0 0;
transform: rotate(-30deg) skewX(-30deg) scaleY(0.864);
position: relative;
bottom: 250px;
background-color: grey;
}
.outterstack …Run Code Online (Sandbox Code Playgroud)我想在我的网页上创建一个垂直滑块。我希望每张幻灯片的高度都是其自己的文本内容的高度。如果我没有设置一定的高度(例如 500 像素),则使用滑动器提供的高度(100%),将创建无限的高度。我只是希望当用户单击每个滑动分页时,每张幻灯片都与文本一样高。我不希望能够用鼠标或触摸来移动幻灯片。使用的版本:Swiper 7.0.1。
var swiper = new Swiper(".mySwiper", {
direction: "vertical",
speed: 600,
allowTouchMove: false,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});Run Code Online (Sandbox Code Playgroud)
.swiper {
width: 100%;
height: 100%;
}
.swiper {
width: 100%;
/*height: 100%;*/
/* height: 500px; */
/* min-height: 500px; */
max-height: 500px;
}
.swiper-slide {
text-align: center;
font-size: 18px;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center; …Run Code Online (Sandbox Code Playgroud)我已经花了好几天的时间来解决这个问题,但我无法解决这个问题,可能是因为缺乏 html2canva 的知识,或者它不想被修复。我唯一想要的是将我的 pdf 放在 a4 大小的单页上,但它总是呈现在两页上。不知道我哪里错了。请提出建议。
\n这是我的代码:
\ndocument.querySelector(\'#temp\').contentEditable = true;\n\nfunction createpdf() {\n let body = document.body\n let html = document.documentElement\n let height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight)\n let element = document.querySelector(\'#temp\')\n let heightCM = height / 35.35\n html2pdf(element, {\n margin: 1,\n filename: \'MyResume.pdf\',\n image: {\n type: \'jpeg\',\n quality: 4\n },\n html2canvas: {\n dpi: 400,\n letterRendering: true,\n scale: 3\n },\n jsPDF: {\n orientation: \'portrait\',\n unit: \'cm\',\n // format: [heightCM, 50]\n format: \'a4\'\n\n }\n }).save()\n}Run Code Online (Sandbox Code Playgroud)\r\n …我有一个 flex-row 元素(例如两条带 flex-wrapped 的行)。当我单击这些元素之一时,应该直接在该元素下打开一个弹出窗口(绿色框)(这就是我需要绝对定位的原因)并且这些弹出窗口都应该具有相同的宽度(与单击哪个元素无关)。
问题是因为这个绝对定位的 div 刚好在被点击的元素下面开始,这个弹出窗口的起点也在 x 轴上变化。但我希望所有的弹出窗口都水平地从同一点开始。
https://jsfiddle.net/h8f73Lpm/24/
这是我的情况的简化版本。由于我们还必须考虑响应性,因此实际的行数和元素数会有所不同。我更喜欢仅使用 css 的解决方案。
.flexlist {
display: flex;
flex-wrap: wrap;
max-width: 700px;
}
.entry {
position: relative;
min-width: 96px;
height: 100px;
border: 1px solid red;
margin: 1px;
}
.selected {
background: red;
}
.absolute {
position: absolute;
left: 0;
top: 100%;
width: 300px;
background: green;
z-index: 1;
height: 80px;
}Run Code Online (Sandbox Code Playgroud)
<div class="flexlist">
<div class="entry"></div>
<div class="entry"></div>
<div class="entry selected">
<div class="absolute"></div>
</div>
<div class="entry"></div>
<div class="entry"></div> …Run Code Online (Sandbox Code Playgroud)我遇到了对我来说意想不到的行为。我想将bodymin-height 设置为视口的高度(100vh),然后div在其中创建一个(具有容器类),它将占据主体的整个高度(100%),以便 div 延伸至少到视口的所有高度。除非这不会发生;实现此结果的唯一方法是将高度设置html为body100%。造成这种情况的技术原因是什么?div 不应该采用其父级 100% 的(最小)高度吗?
在这里你可以找到一个 codepen,其预期行为在 css 末尾被注释掉
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #ddd;
min-height: 100vh;
}
.container {
background: #aaa;
max-width: 500px;
margin: 0 auto;
padding: 1rem;
min-height: 100%;
height: 100%;
}
/* Uncomment for the expected behaviour */
/*
html,
body {
height: 100%
}
*/Run Code Online (Sandbox Code Playgroud)
<div class="container">
<h1>Some generic title</h1>
<p>Some random paragraph</p>
</div>Run Code Online (Sandbox Code Playgroud)
代码是这样的
<div class="linkPillar">
<a href="github"><img src="github.png" alt="GitHub"></a>
<a href="facebook"><img src="fb.png" alt="facebook"></a>
</div>
Run Code Online (Sandbox Code Playgroud)
我想选择 linkPillar 内部的所有 a,而不给每个 a 提供 id。有什么办法可以做到这一点,谢谢
html ×10
css ×9
javascript ×7
bootstrap-4 ×1
css-grid ×1
html-to-pdf ×1
html2canvas ×1
jquery ×1
reactjs ×1
scrollbar ×1
state ×1