row-height 相关问题


更改动态表单控制角度的值

我有这个动态表单控件 我有这个动态表单控件 <form [formGroup]="dynamicFormGroup" (ngSubmit)="onSubmit()" > <div class="row" formArrayName="address" *ngFor="let fields of AddressInfo.controls; let i = index"> <ng-container [formGroupName]="i"> <input type="number" class="form-control height-reset" placeholder="Enter Mobile" name="mobile" formControlName="mobile" /> .. </form> 当我尝试更改字段的值时 this.dynamicFormGroup.controls['mobile'].setValue(''); 或 this.dynamicFormGroup.patchValue({ mobile: '444' }); 该值未更新 任何解决方案谢谢 我认为问题在于您在 formGroup 内的 FormArray 内使用 FormControl。 (只需查看简短的代码片段即可) 所以你的代码应该看起来像这样; this.dynamicFormGroup.controls[index].controls['mobile'].setValue(''); <ng-container [formGroupName]="i">也可能会破坏它。 我建议修改表格的结构,然后找到每个表格的正确“路径”。 就您而言,不清楚 AddressInfo 是什么。相反,将您的代码更改为: <div class="row" formArrayName="address" *ngFor="let fields of addressFormArray.controls; let i = index"> <ng-container [formGroupName]="i"> <input type="number" class="form-control height-reset" placeholder="Enter Mobile" name="mobile" formControlName="mobile"> </ng-container> </div> get addressFormArray() { return this.formMain.get('address') as FormArray; } 用户现在可以添加值。 如果您计划以编程方式编辑该值,则 this.dynamicFormGroup.controls['mobile'].setValue(''); 将不起作用,因为 mobile 是 FormArray 中的 FormControl。然后,要么循环遍历该数组以更改所有值,要么必须澄清应该更改哪个值。


从另一个输入中获取值,而无需在 php 中刷新页面

我有这个 fetch.php 文件 $out=''; while($row = mysqli_fetch_assoc($result)) { $out .= '' .$row["jam_mulai"]. '-.$row["jam_be...


php 中的用户欢迎消息

如何在 php.ini 中创建用户欢迎消息这样已经登录的用户就能够看到他的用户名。 我有这段代码,但它似乎不起作用。 如何在 php.ini 中创建用户欢迎消息这样已经登录的用户就能够看到他的用户名。 我有这个代码,但它似乎不起作用。 <?php $con = mysql_connect("localhost","root","nitoryolai123$%^"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("school", $con); $result = mysql_query("SELECT * FROM users WHERE Username='$username'"); while($row = mysql_fetch_array($result)) { echo $row['Username']; echo "<br />"; } ?> 我正在尝试利用在此登录表单中输入的数据: <form name="form1" method="post" action="verifylogin.php"> <td> <table border="0" cellpadding="3" cellspacing="1" bgcolor=""> <tr> <td colspan="16" height="25" style="background:#5C915C; color:white; border:white 1px solid; text-align: left"><strong><font size="2">Login User</strong></td> </tr> <tr> <td width="30" height="35"><font size="2">Username:</td> <td width="30"><input name="myusername" type="text" id="idnum" maxlength="5"></td> </tr> <tr> <td width="30" height="35" ><font size="2">Password:</td> <td width="30"><input name="mypassword" type="password" id="lname" maxlength="15"></td> </tr> <td align="right" width="30"><td align="right" width="30"><input type="submit" name="Submit" value="Submit" /></td> <td align="right" width="30"><input type="reset" name="Reset" value="Reset"></td></td> </tr> </form> 但是这个 verifylogin.php 似乎很碍事。 <?php $host="localhost"; $username="root"; $password="nitoryolai123$%^"; $db_name="school"; $tbl_name="users"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:userpage.php"); } else { echo "Wrong Username or Password"; } ?> 我该怎么做?当我运行它时,我总是收到此错误: Notice: Undefined variable: username in C:\wamp\www\exp\userpage.php on line 53 您能推荐一个更简单的方法来实现同样的目标吗? $result = mysql_query("SELECT * FROM users WHERE Username='$username'"); 你忘记从某处定义和填充$username 您还需要添加 exit();在以下代码之后: session_register("myusername"); session_register("mypassword"); header("location:userpage.php"); exit(); ## EXIT REQUIRED 如果您不添加此内容并且客户端刷新,则会提示“您确定要重新提交已发布的变量吗?”如果他们单击“是”,那么您所有的登录逻辑将再次执行。在这种情况下,这可能不是致命的事情,但无论如何你都应该拥有它。 最重要的是:如果新用户登录,需要显示不同的名称,而不是显示以前的名称


用 Bootsrap 制作的网站右侧的空间不会消失吗?

无论我做什么,我用 Bootsrap 制作的网站右侧的空白都没有消失。如果有解决办法请告诉我 无论我做什么,我用 Bootsrap 制作的网站右侧的空白都没有消失。如果有解决办法请告诉我 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Contact | Enba Camping</title> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link rel="stylesheet" href="style/style.css"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> </head> <body> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script> <!-- NAV --> <div class="container-fluid"> <div class="row"> <div class="col-sm-12 p-0"> <nav class="navbar navbar-expand-lg bg-body-tertiary p-0 "> <div class="container-fluid bg-dark "> <a class="navbar-brand text-light mb-2" href="index.html">Enba Camping</a> <button class="navbar-toggler btn btn-light btn btn-outline-light bg-light m-2" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon "></span> </button> <div class="collapse navbar-collapse" id="navbarNavAltMarkup"> <div class="navbar-nav ms-auto"> <a class="nav-link text-light text-center" aria-current="page" href="index.html">Home</a> <a class="nav-link text-light text-center" href="aboutus.html">About us</a> <a class="nav-link active text-light text-center" href="contact.html" aria-disabled="true">Contact</a> </div> </div> </div> </nav> </div> </div> </div> <!-- NAV END --> <!-- ABOUT US --> <div class="container-fluid p-0 bg-dark text-light"> <div class="row"> <div class="col-sm-6 ps-0"> <img src="images/lesly-derksen-F4fH5dAfZnE-unsplash.jpg" alt="" class=" d-block w-100 c-img "> </div> <div class="col-sm-6 d-flex justify-content-center align-items-center "> <div class="text-center"> <h2 class="fw-bold display-4 ">Bize Ulaşın</h2> <!-- ABOUT US --> <div class="mb-3"> <label for="exampleFormControlInput1" class="form-label">Adınız</label> <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="Name"> </div> <div class="mb-3"> <label for="exampleFormControlInput1" class="form-label">Email Adres</label> <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="Email Address"> </div> <div class="mb-3"> <label for="exampleFormControlTextarea1" class="form-label">Mesajınız</label> <textarea class="form-control" id="exampleFormControlTextarea1" placeholder="Message" rows="3"></textarea> </div> <div class=" gap-2 d-md-block "> <button class="btn btn-light " type="button">Send</button> </div> </div> </div> </div> </div> <!-- ABOUT US END --> <!-- PRODUCT --> <div class="container mt-sm-5"> <div class="row text-center "> <h1 class="d-flex justify-content-center">Mekanlarımız</h1> <hr> <div class="col-sm-4 mb-2"> <div class="card"> <img src="images/card2.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Orman İçi Karavan Parkı</h5> <p class="card-text">Ormanın içinde konumlanan karavan parkımız, tam anlamıyla bir doğa kaçamağı sunuyor. Ormanın huzurlu atmosferinde kendinizi kaybedin. Karavanınızla konforlu bir konaklama deneyimi yaşayın.</p> <a href="#" class="btn btn-dark">Rezervasyon için tıklayınız </a> </div> </div> </div> <div class="col-sm-4 mb-2"> <div class="card"> <img src="images/card3.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Orman İçi Çadırlı Kamp</h5> <p class="card-text">Orman içi çadırlı kamp alanımız, doğa severler için bir cennet. Gölgeli ağaçlar arasında konumlanan çadırlarımızda, kuş cıvıltıları ve huzur içinde bir konaklama deneyimi sizi bekliyor.</p> <a href="#" class="btn btn-dark">Rezervasyon için tıklayınız</a> </div> </div> </div> <div class="col-sm-4 mb-2"> <div class="card"> <img src="images/card1.jpg" class="card-img-top" alt="..."> <div class="card-body"> <h5 class="card-title">Dağ Evi </h5> <p class="card-text">Dağ evimiz, şehrin gürültüsünden uzak,huzurlu bir konaklama imkanı sunuyor. Ferah odalarımızda dağ manzarasının keyfini çıkarabilir, gölet kenarındaki aktivitelerle vakit geçirebilirsiniz.</p> <a href="#" class="btn btn-dark">Rezervasyon için tıklayınız</a> </div> </div> </div> </div> </div> <!-- PRODUCT END --> <!-- PROJECT --> <div class="row my-4"> <div class="col-sm-12"> <h1 class="d-flex justify-content-center">Galeri</h1> <hr> </div> <div class="col-sm col-6 mb-1"><img src="images/galeri/hichem-meghachou-7I-Rj_E9ihI-unsplash.jpg" alt="" class="w-100 img-thumbnail"> </div> <div class="col-sm col-6 mb-1"><img src="images/galeri/jimmy-conover-J_XuXX9m0KM-unsplash.jpg" alt="" class="w-100 img-thumbnail"> </div> <div class="col-sm col-6 mb-1"><img src="images/galeri/josh-campbell-UbbjVyibFuc-unsplash.jpg" alt="" class="w-100 img-thumbnail"> </div> <div class="col-sm col-6 mb-1"><img src="images/galeri/shelby-cohron-ESNV6KmLJMg-unsplash.jpg" alt="" class="w-100 img-thumbnail"> </div> <div class="col-sm col-6 mb-1"><img src="images/galeri/tegan-mierle-fDostElVhN8-unsplash.jpg" alt="" class="w-100 img-thumbnail"> </div> <div class="col-sm col-6 mb-1"><img src="images/galeri/toa-heftiba-x9I-6yoXrXE-unsplash.jpg" alt="" class="w-100 img-thumbnail"> </div> </div> <!-- PROJECT END --> <!-- FOOTER --> <div class="bg-dark text-light"> <div class="container"> <footer class="pt-5 mt-5 "> <div class="row "> <div class="col-6 col-md-2 mb-3"> <h5>Section</h5> <ul class="nav flex-column "> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Home</a></li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Features</a> </li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Pricing</a> </li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">FAQs</a></li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">About</a> </li> </ul> </div> <div class="col-6 col-md-2 mb-3"> <h5>Section</h5> <ul class="nav flex-column"> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Home</a></li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Features</a> </li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Pricing</a> </li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">FAQs</a></li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">About</a> </li> </ul> </div> <div class="col-6 col-md-2 mb-3"> <h5>Section</h5> <ul class="nav flex-column"> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Home</a></li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Features</a> </li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">Pricing</a> </li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">FAQs</a></li> <li class="nav-item mb-2"><a href="#" class="nav-link p-0 text-light">About</a> </li> </ul> </div> <div class="col-md-5 offset-md-1 mb-3"> <form> <h4> Abone Ol ve Doğanın Güzelliklerini Kaçırma!</h4> <p class="fs-6">Doğanın kucaklayıcı atmosferine adım atmak, huzurla dolu anlar yaşamak ve Enba Camping'in sunduğu özel fırsatları kaçırmamak için hemen abone ol! Sitemize abone olarak, doğanın gizemli güzellikleri, özel indirimler ve etkinliklerden ilk sen haberdar olacaksın.</p> <p class="fs-6"> Unutulmaz anılar biriktirmek ve doğanın kollarında huzurlu bir deneyim yaşamak için abone ol, Enba Camping'in eşsiz dünyasına adımını at! 🏕️✨ </p> <div class="d-flex flex-column flex-sm-row w-100 gap-2"> <label for="newsletter1" class="visually-hidden">Email address</label> <input id="newsletter1" type="text" class="form-control" placeholder="Email address"> <button class="btn btn-primary" type="button">Subscribe</button> </div> </form> </div> </div> <div class="d-flex flex-column flex-sm-row justify-content-between border-top"> <p>© 2023 Company, Inc. All rights reserved.</p> <ul class="list-unstyled d-flex"> <li class="ms-3"><a class="link-body-emphasis" href="#"><svg class="bi" width="24" height="24"> <use xlink:href="#twitter"></use> </svg></a></li> <li class="ms-3"><a class="link-body-emphasis" href="#"><svg class="bi" width="24" height="24"> <use xlink:href="#instagram"></use> </svg></a></li> <li class="ms-3"><a class="link-body-emphasis" href="#"><svg class="bi" width="24" height="24"> <use xlink:href="#facebook"></use> </svg></a></li> </ul> </div> </footer> </div> </div> <!-- FOOTER END --> </body> </html> 和CSS .jumb { vertical-align: inherit; } p { font-size: 24px; } .c-item { height: 480px; } .c-img { height: 100%; object-fit: cover; filter:brightness(0.9) } 这里。我不希望页面左右移动。我想让它适合全屏,但容器结构溢出了 请将这段代码添加到您的 CSS 文件中。然后,它就会起作用。 .row{ margin-right: 0px; }


防止重新渲染

帮助解决Row组件重新渲染的问题。 我有一个父 List 组件,里面有一个 Row 组件列表。 Row里面有一个渲染计数器,renders。 我需要那个...


向垫子表添加额外的行

所以我有一张垫子桌 所以我有一张垫子桌 <mat-table class="table" cdkDropList cdkDropListOrientation="horizontal" (cdkDropListDropped)="tableDrop($event)" [dataSource]="tableDataSource"> <ng-container *ngFor="let column of columns; let i = index" [matColumnDef]="column.name"> <mat-header-cell *matHeaderCellDef cdkDrag dkDragLockAxis="x" cdkDragBoundary="mat-header-row"> {{ column.title }} </mat-header-cell> <mat-cell *matCellDef="let element"> {{ element[column.name] }} </mat-cell> </ng-container> <mat-header-row class="tableHeader" *matHeaderRowDef="tableDisplayedColumns" #tableHeaderRow> </mat-header-row> <mat-row class="tableRow" *matRowDef="let row; columns: tableDisplayedColumns;" [class.selected-row]="tableSelectedRows.has(row)" (click)="selectUnselectRow(row)"> </mat-row> </mat-table> 但我需要在表标题下为相应的行过滤器添加一行。我尝试在标题和实际行声明之间添加 <mat-row> ,但是由于过滤器是不同的输入(例如数字、自动完成选择和多选),我无法 *ngFor 它们(而且我不是当然我是否能够) 编辑:忘记发布过滤器 HTML <div class="filterGroup"> <mat-form-field class="filterField"> <input matInput type="number" (keydown)="updateManualPage(1)" placeholder="Filter za param1" formControlName="filterParam1"> </mat-form-field> <mat-form-field class="filterField"> <input matInput (keydown)="updateManualPage(1)" placeholder="Filter za param2" formControlName="filterParam2" [matAutocomplete]="autoSingleSelect"> <mat-autocomplete #autoSingleSelect="matAutocomplete" class="filterSelect" panelClass="filterSelect"> <mat-option *ngFor="let option of dropdownSingleFilteredOptions | async" [value]="option.param2"> {{option.param2}} </mat-option> </mat-autocomplete> </mat-form-field> <mat-form-field class="filterField"> <mat-select class="filterMultiselect" placeholder="Filter za param3" formControlName="filterParam3" multiple panelClass="filterMultiselect"> <mat-option *ngFor="let option of tableDataSource.data" [value]="option.param3"> {{option.param3}} </mat-option> </mat-select> </mat-form-field> </div> 以及相关组件.ts tableDisplayedColumns: string[] = ['param1', 'param2', 'param3']; columns: any[] = [ { name: 'param1', title: 'Param1' }, { name: 'param2', title: 'Param2' }, { name: 'param3', title: 'Param3' } ]; 为了解决这个问题,我设法通过删除 *ngFor 并手动放入过滤器来做到这一点。 <mat-table class="table" cdkDropList cdkDropListOrientation="horizontal" (cdkDropListDropped)="tableDrop($event)" [dataSource]="tableDataSource"> <ng-container matColumnDef="param1"> <mat-header-cell *matHeaderCellDef cdkDrag cdkDragLockAxis="x" cdkDragBoundary="mat-header-row" [cdkDragStartDelay]="100"> Param1 <mat-form-field class="filterField"> <input matInput type="number" (keydown)="updateManualPage(1)" placeholder="Filter" formControlName="filterParam1"> </mat-form-field> </mat-header-cell> <mat-cell *matCellDef="let data"> <span>{{data.param1}}</span> </mat-cell> </ng-container> <ng-container matColumnDef="param2"> <mat-header-cell *matHeaderCellDef cdkDrag cdkDragLockAxis="x" cdkDragBoundary="mat-header-row" [cdkDragStartDelay]="100"> Param2 <mat-form-field class="filterField"> <input matInput (keydown)="updateManualPage(1)" placeholder="Filter" formControlName="filterParam2" [matAutocomplete]="autoSingleSelect"> <mat-autocomplete #autoSingleSelect="matAutocomplete" class="filterSelect" panelClass="filterSelect"> <mat-option *ngFor="let option of dropdownSingleFilteredOptions | async" [value]="option.param2"> {{option.param2}} </mat-option> </mat-autocomplete> </mat-form-field> </mat-header-cell> <mat-cell *matCellDef="let data"> <span>{{data.param2}}</span> </mat-cell> </ng-container> <ng-container matColumnDef="param3"> <mat-header-cell *matHeaderCellDef cdkDrag cdkDragLockAxis="x" cdkDragBoundary="mat-header-row" [cdkDragStartDelay]="100"> Param3 <mat-form-field class="filterField"> <mat-select class="filterMultiselect" placeholder="Filter" formControlName="filterParam3" multiple panelClass="filterMultiselect"> <mat-option *ngFor="let option of tableDataSource.data" [value]="option.param3"> {{option.param3}} </mat-option> </mat-select> </mat-form-field> </mat-header-cell> <mat-cell *matCellDef="let data"> <span>{{data.param3}}</span> </mat-cell> </ng-container> <mat-header-row class="tableHeader" *matHeaderRowDef="tableDisplayedColumns" #tableHeaderRow> </mat-header-row> <mat-row class="tableRow" *matRowDef="let row; columns: tableDisplayedColumns;" [class.selected-row]="tableSelectedRows.has(row)" (click)="selectUnselectRow(row)"> </mat-row> </mat-table>


查询结果:$row[0]是什么

我知道这听起来像是一个编程新手提出的愚蠢问题,但我只是想确保我理解正确。 查询后,$row[0] 代表/结果是什么? 我的理解吗...


React-Pixi 入口/react-pixi 中的屏蔽

我用于精灵的图像比所需的大得多(910px)。我需要动态更改容器的高度,遮盖图像。 有谁知道如何做到这一点? 我用于精灵的图像比所需的大得多(910 像素)。我需要动态更改容器的高度,遮盖图像。 有人知道该怎么做吗? <Container x={x} y={y} width={width} height={height}> <Sprite image={image} anchor={[0, 0]} x={0} y={0} width={width} height={910} rotation={0} /> </Container> @inlet/react-pixi: "^1.1.9" pixi.js: "^5.2.0" react: "^16.12.0" react-dom: "^16.12.0" 不幸的是,这也不起作用,因为纹理保持静态,而矩形四处移动 <Graphics draw={(g) => { g.clear() const texture = new PIXI.Texture.from(image) g.beginTextureFill(texture) g.drawRect(x, y, width, height) g.endFill() }} /> 试试这个: const maskRef = useRef() <Container mask={maskRef?.current} x={x} y={y} width={width} height={height}> <Graphics name="mask" draw={React.useCallback( (g) => { g.beginFill(0x000000) g.drawRect(0, 0, size.width + 3, size.height + 3) g.endFill() }, [width, height] )} ref={maskRef} /> <Sprite image={image} anchor={[0, 0]} x={0} y={0} width={width} height={910} rotation={0} /> </Container> 官方文档位于此处,解释其工作原理和局限性


如何解决错误:调用字符串上的成员函数 row()?

我设置了一个网络应用程序,带有注册表单。当我尝试通过此表单将数据插入数据库时,出现以下错误: 未捕获的错误:调用字符串上的成员函数 row() ...


通过检查行的值将数据从宽格式转换为长格式

我有以下数据 数据<-structure(list(id = "R_88j7lG37gLfxk22", t1_choice = "2", t2_choice = "1", t3_choice = "1", t4_choice = "2"), row.


SSAS/Power BI 行级安全性

我一直在使用 radacad 创建的一些非常有用的文章(例如 https://radacad.com/dynamic-row-level-security-with-manager-level-access-in-power-bi),使我能够添加一些行级安全...


Symfony/Twig 在 if 条件下设置变量

我知道这真的很微不足道,也不那么重要,但它可以节省我的一生...... 您知道可以在 PHP 中的 if 块中声明变量 if( $row = $sql->fetch ){ //做一些事情...


如何在Bootstrap中管理较小尺寸的页面?

.$s['姓氏']. <div class="input-group col-sm-10"> <span class="input-group-addon col-sm-4 text-right border">.$s['Surname'].</span> <input id="msg" type="text" class="form-control col-sm-6" name="msg" placeholder="Enter Marks"> 嗨,我尝试使用 2 列,但是在手机上,控件的行为似乎有所不同 如何让控件在小屏幕上保持常规尺寸? 谢谢你。 当你在代码中说 col-sm-6 意味着从小尺寸(576px)开始采用这个尺寸 <div class="container-fluid"> <div class="row"> <div class="col-12 col-sm-8 col-md-6"></div> <div class="col-12 col-sm-4 col-md-6"></div> </div> </div> // <div class="col-12 col-sm-8 col-md-6"></div> 这段代码传达的概念是 col-12:通常占据所有小于small的列 col-sm-8:从小模式开始占据 8 列(576px) col-md-6:从中模式开始占据 6 列(768px) 我们还可以按需使用col-lg,这取决于我们的需求。 我希望我明白你的意思并且我能够很好地帮助你 你应该尝试下面的代码, <div class="container"> <div class="row"> <div class="col"> Here col is used for auto width (if row has multiple elements in column so col width will be adjusted automatically by dividing them) </div> </div> </div> 或 <div class="container"> <div class="row"> <div class="col-12"> Here col-12 is used so this will get entire width of the viewport (12 grids) as it is specified.. </div> <div class="col"> Here col is used so as above div has col-12 class so this col will get auto width and there is no more columns in this row so this will get 100% of width. </div> </div> </div> 注意:适用于移动设备等小型设备(<576px) only col is used and col itself uses all 12 grids but if we have multiple columns in row and we want to give different grids to them, then we have to specify as col-6, col-4, col-12 etc as per requirement... 有关更多详细信息,我已附加一些链接并仅供参考... 引导网格系统 谢谢... 阿拉普·乔希


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

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; }


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


滚动时仅触发一次功能

我想在div滚动到视口时启动一个函数。我的问题是,每次我继续滚动时,该功能都会再次触发/启动。 HTML: <... 我想在 div 滚动到视口中时启动一个函数。我的问题是,每次我继续滚动时,该功能都会再次触发/启动。 HTML: <div class="box"></div> JS: $(document).ready(function() { function start() { alert("hello"); } $(window).scroll(function() { if ( $(window).scrollTop() >= $('.box').offset().top - ($(window).height() / 2)) { $(".box").addClass("green"); start(); } else { $(".box").removeClass("green"); } }); }); 总结一下:当div滚动到视口中时,应该启动“start”函数。但触发一次后就不能再触发了。 小提琴 您可以设置一个标志,例如: var started = false; function start() { if(!started) { alert("hello"); } started = true; } 演示 $(document).ready(function() { var started = 0; function start() { if(started==0) { alert("Alert only once"); } started = 1; } $(window).scroll(function() { if ( $(window).scrollTop() >= $('.box').offset().top - ($(window).height() / 2)) { $(".box").addClass("green"); start(); } else { $(".box").removeClass("green"); } }); }); *{margin:0;} .box { background: red; height: 200px; width: 100%; margin: 800px 0 800px 0; } .green { background: green; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <br /> <center> <br /> <h1>scroll down</h1> </center> <div class="box"></div> 有很多方法可以解决这个问题。您可以删除事件侦听器(因为您使用的是 jQuery,所以我将使用 on 和 off 方法): $(window).on('scroll', function() { if ( $(window).scrollTop() >= $('.box').offset().top - ($(window).height() / 2)) { $(".box").addClass("green"); start(); } else { $(".box").removeClass("green"); } $(window).off('scroll'); }); 如果你希望窗口滚动方法在启动方法满足要求后停止..你可以这样做 $(document).ready(function() { var toggleScroll = false; function start() { alert("hello"); } $(window).one("scroll", checkToggleScroll); function checkToggleScroll(){ if ( $(window).scrollTop() >= $('.box').offset().top - ($(window).height() / 2)) { $(".box").addClass("green"); toggleScroll = true; start(); } else { $(".box").removeClass("green"); } if(!toggleScroll){ $(window).one("scroll", checkToggleScroll); } } }); 当start()没有类$(".box)(在一定量的滚动后添加)时,只需运行"green"函数。 $(document).ready(function() { function start() { alert("hello"); } $(window).scroll(function() { if ($(window).scrollTop() >= $('.box').offset().top - ($(window).height() / 2)) { if (!$(".box").hasClass("green")) { $(".box").addClass("green"); start(); } } else { $(".box").removeClass("green"); } }); }); .box { background: red; height: 200px; width: 100%; margin: 800px 0 800px 0; } .green { background: green; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="box"></div>


为什么我的反应虚拟列表不显示滚动条,除非我确保高度低于 rowCount*rowHeight?

我正在使用 "react-virtualized": "9.22.5",我正在尝试渲染一个列表。 当我经过时 我正在使用 "react-virtualized": "9.22.5",并且我正在尝试渲染一个列表。 当我经过时 <List height={myList.length * 30} rowHeight={30} rowCount={myList.length} width={240} style={{maxHeight: 657}} rowRenderer={({ index, key, style }) => {...} /> 我只得到前 21 项,即使 myList 更长。这意味着我没有滚动条,并且其余项目不可见。如果我使用 rowCount={myList.length + 1},它会神奇地正确计算行数,并且我会得到滚动条。或者,设置 height={myList.length*30 - 0.001} 也可以。 console.log(myList.length) 显示正确的长度。 发生什么事了? 事实证明,List不知道它的maxHeight是什么——它“认为”它以全高显示。由于 height 与 rowCount 所需的一样大,因此不会显示滚动条。要显示滚动条,无论其他样式如何,height 都必须小于 rowCount*rowHeight。 我的解决方案是写 List 而不使用 maxHeight,但否则我会使用 -0.001 hack。


“可见性:隐藏”元素导致出现空白/滚动条

我有一个问题,其中具有可见性的元素:隐藏;即使 max-height: 0 仍然占用空间;设置,导致滚动条出现在右侧。 JSFiddle 示例 正如您在示例中看到的...


仅在页面底部添加边距

我有一个始终固定在视图底部的 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>


ClosedXML 导出数据网格到 Excel 仅 10 行

我有一个包含 60 行数据的数据网格和一个将其导入 Excel 的按钮: 我有一个包含 60 行数据的数据网格和一个将其导入 Excel 的按钮: <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Source}" CanUserAddRows="False" HeadersVisibility="All" Name="dgDisplay"> <DataGrid.Columns> <DataGridTextColumn Header="Day" Binding="{Binding Day}"/> <DataGridTextColumn Header="Data" Binding="{Binding Data}"/> </DataGrid.Columns> </DataGrid> <Button Command="{Binding SaveDataGridToExcelCommand}" CommandParameter="{Binding ElementName=dgDisplay}"/> 其中 Day 和 Data 只是一些随机生成的 int 数据。 我的代码使用 ClosedXML 将数据从中导出到 Excel,它使用 MainWindowViewModel: ObservableObject 调用 MVVM.Toolkit。 [RelayCommand] public void SaveDataGridToExcel(DataGrid dataGrid) { DataTable dt = new DataTable(); foreach (DataGridColumn column in dataGrid.Columns) { dt.Columns.Add(column.Header.ToString()); } foreach (var item in dataGrid.Items) { DataRow dr = dt.NewRow(); bool rowHasData = false; for (int i = 0; i < dataGrid.Columns.Count; i++) { var cellContent = dataGrid.Columns[i].GetCellContent(item); if (cellContent is TextBlock textBlock) { //check if row empty, dont add this row.I add it on purpose to check //if the datagrid recognite the rest 50 rows not have data. It actually //dont save those data dr[i] = textBlock.Text; if (!string.IsNullOrEmpty(textBlock.Text)) { rowHasData = true; } } } if (rowHasData) { dt.Rows.Add(dr); } } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt, "Sheet1"); wb.SaveAs(saveFileDialog.FileName); } } } 但是保存的60行结果只显示了10行数据,其余50行都是空的。如果疑问为什么不使用Microsoft.Interop.Excel,那是因为该包不适合我的 Excel 版本。我没有在 ClosedXML 中看到任何对此有限制或许可的地方,所以我想知道为什么。如有任何帮助,我们将不胜感激。 在浏览 github 几个小时后,我自己找到了答案。 我没有访问单元格内容,而是直接从 DataGrid 的 ItemsSource 访问数据: public void SaveDataGridToExcel(DataGrid dataGrid) { DataTable dataTable = new DataTable(); foreach (DataGridColumn column in dataGrid.Columns) { dataTable.Columns.Add(column.Header.ToString()); } var itemsSource = dataGrid.ItemsSource as IEnumerable; if (itemsSource != null) { foreach (var item in itemsSource) { var properties = item.GetType().GetProperties(); var row = dataTable.NewRow(); foreach (var property in properties) { row[property.Name] = property.GetValue(item); } dataTable.Rows.Add(row); } } //show dialog... }


在 Angular 中打开模态时出现ExpressionChangedAfterItHasBeenCheckedError

` `<ngx-datatable-column *ngIf="search_type ==='booking'" [width]="50" [sortable]="false" [canAutoResize]="false" [draggable]="false" [resizeable]="false"> <ng-template ngx-datatable-cell-template let-row="row" let-value="value"> <span class="fa fa-user-plus font-medium-3 text-primary cursor-pointer pl-1" (click)="onUpdateBookingLinguist(row)"></span> </ng-template> </ngx-datatable-column>` 上面是我的html代码,下面是我的ts代码 ` onUpdateBookingLinguist(linguist: Linguist) { const modalRef = this.modalService.open(ScheduledBookingModalComponent, { size: 'lg' }); modalRef.componentInstance.linguist_other_bookings = linguist['scheduled_booking']; modalRef.result.then((result) => { if (!result) { return; } this.cdr.detectChanges(); }).catch((e) => { }); this.cdr.detectChanges(); }` 我试图从 ngx-datatable-column 打开模式,但收到此错误 错误错误:NG0100:ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后已更改。上一个值:“datatable-body-cell sort-active active”。当前值:'datatable-body-cell sort-active'.. 欲了解更多信息,请访问 https://angular.io/errors/NG0100 我尝试使用 ChangeDetectorRef.detectChanges() 手动触发更改检测,但仍然收到错误。 当您修改 Angular 在其更改检测周期期间也尝试检查或更新的属性时,通常会出现此错误。 因此您可以使用 ChangeDetectorRef 在特定情况下手动触发更改检测。通过从 ChangeDetectorRef 调用 detectorChanges(),您可以手动指示 Angular 对该组件及其子组件重新运行更改检测,从而可能解决问题 这是如何在组件中使用ChangeDetectorRef 的示例 构造函数(私有 cdr:ChangeDetectorRef){} ngAfterContentChecked() { this.cdr.detectChanges(); }


对 HTML 中的 <img> 标签感到困惑:它是空的吗?为什么有这些属性?

我对HTML中的标签感到困惑。人们说它是一个空标签,但它可以具有 src、alt、width、height 和 id 等属性。有人可以澄清它是否真的是空的并解释为什么它


绑定了formControlName后,如何在html中使用它?

我当前有问题的 html 部分是这样的 ... 我的 html 当前有问题的部分是这个 <div class="psi-list"> <div class="flex-row" *ngFor="let item of psiList; index as i"> <p class="row-psi">{{ item.psi }}</p> <button class="icon-btn" (click)="deletePsi(item.psi)"><i class="cil-trash"></i></button> <button class="icon-btn" (click)="item.toggle = !item.toggle"><i class="cil-pen-alt"></i></button> <form [formGroup]="psiEditForm" id="psi-edit-form" class="form-horizontal" [hidden]="!item.toggle"> <input class="psi-input" type="text" placeholder="Update PSI here..." [(ngModel)]="psiEdit" [ngClass]="{'is-valid': !checkControlValidation(psiEditForm.controls.psi) && psiEditForm.controls.psi.touched, 'is-invalid': checkControlValidation(psiEditForm.controls.psi)}" (keydown.enter)="!psiEditForm.controls.psi.invalid ? editPsi(item.psi) : clearPsiEdit()" formControlName="psi" /> <div class="help-block validation-warning" *ngIf="checkControlValidation(psiEditForm.controls.psi)"><i class="fa fa-exclamation fa-lg"></i>Please Enter a Valid 2 Letter PSI</div> </form> </div> </div> 我使用 formControlName“psi”将控件传递给 .ts 文件中的 checkControlValidation 方法。然而,这会导致功能问题。每当我在一个输入框中输入内容时,它都会将其输入到 *ngFor 中的所有输入框中。 当我将表单控件名称更改为这个时 - [formControlName]="item.psi" 它将名称绑定到与其相关的项目,因此理论上我可以通过它来解决我的问题。但是,当我将 psiEditForm.controls.psi 的所有实例更改为 psiEditForm.controls.item.psi 时,我收到很多 TS2339 错误。 我有什么想法可以使用它吗?抱歉,我知道这可能措辞很糟糕 尝试这样 <div class="psi-list"> <div class="flex-row" *ngFor="let item of psiList; index as i"> <p class="row-psi">{{ item.psi }}</p> <button class="icon-btn" (click)="deletePsi(item.psi)"><i class="cil-trash"></i></button> <button class="icon-btn" (click)="item.toggle = !item.toggle"><i class="cil-pen-alt"></i></button> <form [formGroup]="psiEditForm" id="psi-edit-form" class="form-horizontal" [hidden]="!item.toggle"> <input class="psi-input" type="text" placeholder="Update PSI here..." [(ngModel)]="psiEdit" [ngModelOptions]="{standalone: true}" [ngClass]="{'is-valid': !checkControlValidation(psiEditForm.controls.psi) && psiEditForm.controls.psi.touched, 'is-invalid': checkControlValidation(psiEditForm.controls.psi)}" (keydown.enter)="!psiEditForm.controls.psi.invalid ? editPsi(item.psi) : clearPsiEdit()" formControlName="psi" /> <div class="help-block validation-warning" *ngIf="checkControlValidation(psiEditForm.controls.psi)"> <i class="fa fa-exclamation fa-lg"></i>Please Enter a Valid 2 Letter PSI </div> </form> </div> </div>


VS Code 中的虚假错误

我正在编写 Tera 代码。 {% 扩展“基”%} {% 块内容 %} {{标题}}! 我正在编写 Tera 代码。 {% extends "base" %} {% block content %} <main> <h1>{{ title }}!</h1> <div class="telkiniu-sarasas"> <div class="row"> <div class="telkinio-pavadinimas headeris">Pavadinimas</div> <div class="telkinio-adresas headeris">Adresas</div> </div> {% for telkinys in telkiniai %} <div class="row" onclick="telkinys( {{ telkinys.id }} )"> <div class="telkinio-pavadinimas">{{ telkinys.pavadinimas }}</div> <div class="telkinio-adresas">{{ telkinys.adresas }}</div> </div> {% endfor %} </div> </main> {% endblock content %} 我在 javascript 代码上遇到了 3 个错误 <div class="row" onclick="telkinys( {{ telkinys.id }} )"> 仅 html 行没有问题。 但运行代码一切都按预期工作。因为{{ telkinys.id }}被替换为数字 <div class="row" onclick="telkinys( 1 )"> 如何从 VS Code 中删除错误消息?我认为 VS Code 将 Javascript 内的 Tera 代码解释为 Javascript 代码。而且 VS Code 不知道它会被数字替换。 我想不出有什么办法可以解决它。 附注 搜索后我发现.tera与HTML相关联,所以我打开设置 - >扩展 - > HTML 并在这里进行了搜索。找到两个地点: HTML > 格式:缩进车把 未选择格式和缩进 {{#foo}} 和 {{/foo}},因此我选择了它并收到有关错误索引或其他内容的错误(但我使用的不是 Handlebars,而是 Tera,所以它可能对我没有影响代码)。 第二: HTML > 格式:模板 尊重 django、erb、handlebars 和 php 模板语言标签。 选择这个也出现同样的错误。而且这也没有 Tera。 但没有成功:) 我找到了解决问题的方法。 Tera 模板基于 Jinja2,因此我从 VS Code 中删除了 Tera 扩展并添加了“Better Jinja”扩展。 之后,我使用这个答案将 .tera 扩展名关联到 jinja https://stackoverflow.com/a/51228725/3857286 现在我有了很好的语法突出显示,并且 javascript 代码中的 tera 标签没有问题。


如何在React Native中显示图像的顶部,

这是我现在的情况,我的形象是这样的 这是我当前的代码 这是我现在的情况,我的形象是这样的 这是我当前的代码 <View> <Image style={{width: '100%', height: 285}} source={{ uri: `${posterPath + data?.poster_path}`, }} resizeMode="cover" /> <Text>{data?.title}</Text> </View> 我希望我的图像看起来像这样 (这只是一个例子) 我知道在普通的CSS中我们是否可以使用object-position,但不幸的是React Native并不直接支持object-positionCSS属性,所以我很困惑如何实现这个 您需要使用 Flex:1,它使用整个屏幕,然后相应地定位和调整图像大小。 <View style={{flex:1}}> <Image style={{width:'100%', height:285}} source={{ uri: `${posterPath + data?.poster_path}`, }} resizeMode="cover" /> <Text>{data?.title}</Text> </View>


似乎无法让下载属性发挥作用

我刚刚开始学习 html 所以我想尝试使用 download 属性 我刚刚开始学习 html,所以我想尝试使用下载属性 <a href="../images/clunk.jfif" download="ur_mum"> <img src="../images/clunk.jfif" alt="ur mum" width="200" height="200"> </a> 图像存储在同一个网站上,但是当我单击它而不是下载时,它只会使图像全屏显示。 我尝试尽可能地排除故障,但没有成功 我能找到的关于为什么某些文件类型发生这种情况但并非所有文件类型的原因是这个答案关于pdf下载与预览的类似问题 - 如果可以的话,请将以下标头添加到服务器端的图像响应中: Content-Disposition: attachment; filename=clunk.jfif 或者,您可以使用自定义 onclick 处理程序替换锚标记,该处理程序将图像转换为数据 URL 并触发下载: <img src="../images/clunk.jfif" width="200" height="200" onclick="downloadImage(this)"> const downloadImage = async (img) => { // fetch the image's media type const mediaType = fetch(img.currentSrc, { method: 'HEAD' }) .then(res => res.headers.get('content-type')) .catch(() => 'image/png' /* default to png if request fails */) // place the image on a canvas element const canv = Object.assign(document.createElement('canvas'), { width: img.naturalWidth, height: img.naturalHeight, }) const ctx = canv.getContext('2d') ctx.drawImage(img, 0, 0) // download the canvas data const a = Object.assign(document.createElement('a'), { download: 'filename', href: canv.toDataURL(await mediaType), }) a.click() }


子控件中的绑定命令?

我有一个 UserControl,用作窗口对话框的“模板”。 它包含一个关闭按钮和一个取消按钮。 我有一个 UserControl,用作窗口对话框的“模板”。 它包含一个关闭按钮和一个取消按钮。 <UserControl x:Class="TombLib.WPF.Controls.WindowControlButtons" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:TombLib.WPF.Controls" mc:Ignorable="d" xmlns:darkUI="clr-namespace:DarkUI.WPF;assembly=DarkUI.WPF" xmlns:vm="clr-namespace:TombLib.WPF.ViewModels" xmlns:sg="clr-namespace:SpacedGridControl;assembly=SpacedGridControl" d:DesignHeight="100" d:DesignWidth="300" x:Name="root"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Height="Auto" Orientation="Horizontal"> <Button Name="oKButton" Margin="{x:Static darkUI:Defaults.MediumThickness}" Width="100" Height="Auto" Command="{Binding Close}" CommandParameter="{Binding Window}" Content="OK"></Button> <Button Name="cancelButton" Margin="{x:Static darkUI:Defaults.MediumThickness}" Width="100" Height="Auto" Command="{Binding Path=Cancel}" CommandParameter="{Binding Window}" Content="Cancel"></Button> </StackPanel> </UserControl> public partial class WindowControlButtons : UserControl { public static readonly DependencyProperty CancelProperty = DependencyProperty.Register( nameof(Cancel), typeof(ICommand), typeof(WindowControlButtons), new PropertyMetadata(null)); public ICommand Cancel { get { return (ICommand)GetValue(CancelProperty); } set { SetValue(CancelProperty, value); } } public static readonly DependencyProperty CloseProperty = DependencyProperty.Register( nameof(Close), typeof(ICommand), typeof(WindowControlButtons), new PropertyMetadata(null)); public ICommand Close { get { return (ICommand)GetValue(CloseProperty); } set { SetValue(CloseProperty, value); } } public static readonly DependencyProperty WindowParameter = DependencyProperty.Register( nameof(Window), typeof(object), typeof(WindowControlButtons), new PropertyMetadata(null)); public object? Window { get { return GetValue(WindowParameter); } set { SetValue(WindowParameter, value); } } public WindowControlButtons() { InitializeComponent(); } } 我想在以下窗口中使用它: <Window x:Class="TombLib.WPF.Windows.SelectIdWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TombLib.WPF.Windows" mc:Ignorable="d" xmlns:ctrl="clr-namespace:TombLib.WPF.Controls" xmlns:vm="clr-namespace:TombLib.WPF.ViewModels" xmlns:sg="clr-namespace:SpacedGridControl;assembly=SpacedGridControl" xmlns:darkUI="clr-namespace:DarkUI.WPF;assembly=DarkUI.WPF" Title="SelectIdWindow" Height="100" Width="300" d:DataContext="{d:DesignInstance Type=vm:SelectIdViewModel }" x:Name="Self"> <sg:SpacedGrid Margin="{x:Static darkUI:Defaults.MediumThickness}"> <!-- REDACTED --> <ctrl:WindowControlButtons DataContext="{Binding ElementName=Self}" Window="{Binding ElementName=Self, Mode=OneWay}" Close="{Binding CloseCommand,Mode=OneWay}" Cancel="{Binding CancelCommand,Mode=OneWay}" Height="Auto" Width="Auto" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Right"/> </sg:SpacedGrid> </Window> public partial class SelectIdWindow : Window { public ICommand? CloseCommand { get; set; } public ICommand? CancelCommand { get; set; } public SelectIdWindow() { CloseCommand = new WindowCloseCommand(); InitializeComponent(); } } public class SelectIdViewModel { public string RequestedId { get; set; } = string.Empty; public IEnumerable<string> TakenIds { get; set;} public SelectIdViewModel(IEnumerable<string> takenIDs) { TakenIds = takenIDs; } } 但是,当我打开窗口时如下: SelectIdWindow w = new SelectIdWindow(); var takenIDs = Entities.Select(kv => kv.Key.Name); w.DataContext = new SelectIdViewModel(takenIDs); w.ShowDialog(); 我在绑定 WindowControlButtons 时收到以下错误: DataContext 显式设置为 Self,它应该代表 Window,而不是 ViewModel。我在这里做错了什么? 绑定错误表明问题出在 Button.ICommand 属性上: 要修复此问题,请在 WindowControlButtons 绑定中添加 ElementName=root,以便绑定到声明的依赖项属性而不是 DataContext: <UserControl x:Class="TombLib.WPF.Controls.WindowControlButtons" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:TombLib.WPF.Controls" mc:Ignorable="d" xmlns:darkUI="clr-namespace:DarkUI.WPF;assembly=DarkUI.WPF" xmlns:vm="clr-namespace:TombLib.WPF.ViewModels" xmlns:sg="clr-namespace:SpacedGridControl;assembly=SpacedGridControl" d:DesignHeight="100" d:DesignWidth="300" x:Name="root"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Right" Height="Auto" Orientation="Horizontal"> <Button Name="oKButton" ... Command="{Binding Close, ElementName=root}" CommandParameter="{Binding Window, ElementName=root}" Content="OK"/> <Button Name="cancelButton" ... Command="{Binding Path=Cancel, ElementName=root}" CommandParameter="{Binding Window, ElementName=root}" Content="Cancel"/> </StackPanel> </UserControl>


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> 内。 我无法在垫子工具栏中填充图像 有什么帮助吗?


这个标题如何粘贴?

这是我的 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>


防止打开的窗口覆盖 opener 的 `close` 方法

我有一个 test1.html 文件,仅包含以下代码: janela = window.open("http://localhost/test2.html","_blank","width=1000,height=400,left=600,top=0"); </...</desc> <question vote="1"> <p>我有一个 <pre><code>test1.html</code></pre> 文件,其中仅包含以下代码:</p> <pre><code>&lt;script&gt; janela = window.open(&#34;http://localhost/test2.html&#34;,&#34;_blank&#34;,&#34;width=1000,height=400,left=600,top=0&#34;); &lt;/script&gt; </code></pre> <p>上面的代码将打开窗口<pre><code>test2.html</code></pre>,其中包含以下代码:</p> <pre><code>&lt;script&gt; opener.window.janela.close = null; &lt;/script&gt; </code></pre> <p>现在,在窗口 <pre><code>test1.html</code></pre> 上,如果我尝试关闭刚刚使用 <pre><code>janela.close()</code></pre> 打开的窗口,我将无法这样做。</p> <p>我知道在 <pre><code>noopener</code></pre> 方法中使用 <pre><code>window.open</code></pre> 会阻止 <pre><code>test2.html</code></pre> 访问 <pre><code>test1.html</code></pre> 但是它也会阻止我在 <pre><code>test1.html</code></pre> 关闭 <pre><code>test2.html</code></pre>。</p> <p>那么我怎样才能可靠地打开 <pre><code>window</code></pre> 并能够在将来自信地关闭它?</p> <p><strong>根据@mplungjan</strong></p>进行编辑 <p>在@mplungjan的帮助下,我做到了:</p> <pre><code>myClose = window.close; janela = window.open(&#34;https://a2eestrutural.eng.br/?fdfk&#34;,&#34;_blank&#34;,&#34;width=1000,height=400,left=600,top=20&#34;); janela.myClose = window.myClose; </code></pre> <p>窗口打开后,我尝试执行<pre><code>janela.myClose();</code></pre>并收到此错误消息:</p> <pre><code>An attempt was made to break through the security policy of the user agent. </code></pre> <p>知道我该如何继续吗?</p> </question> <answer tick="false" vote="0"> <p>为什么要有这个代码?如果您可以控制打开的内容...</p> <p>无论如何,请在打开窗口的脚本之前尝试此操作</p> <pre><code>const myClose = window.close; const janela = window.open(&#34;http://localhost/test2.html&#34;,&#34;_blank&#34;,&#34;width=1000,height=400,left=600,top=0&#34;); .... janela.myClose() </code></pre> </answer> </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>


文本区域高度的 CSS 样式不起作用

元素的默认大小对于我的使用来说太小了,我尝试使用以下CSS代码自定义高度: 文本区域{ 宽度:400px; 高度:150px; } html </desc> <question vote="0"> <p><pre><code><textarea></code></pre>元素的默认大小对于我的使用来说太小了,我尝试使用以下CSS代码自定义高度:</p> <pre><code>textarea { width:400px; height:150px; } </code></pre> <p>html 文本区域:</p> <pre><code><li> Body*:<br> <textarea name="body"></textarea> </li> </code></pre> <p>但这行不通。有什么解决办法吗??</p> <p>P.S:我使用的是 Mozilla firefox。</p> </question> <answer tick="false" vote="2"> <p>效果很好。看这个<a href="http://jsfiddle.net/qhqLV/" rel="nofollow noreferrer">http://jsfiddle.net/qhqLV/</a></p> <p>你的html代码</p> <pre><code><li> Body*:<br> <textarea name="body"></textarea> </li> </code></pre> <p>你的CSS</p> <pre><code>textarea { width:400px; height:150px; } </code></pre> <p>注意:调试代码并检查父元素的宽度和高度。我认为这就是问题所在。可能是文本区域在执行过程中接受任何其他样式。</p> </answer> </body></html>


React CSS 导入

在我的 Home.js 中我有以下代码 从“反应”导入反应; 导入'./Home.css'; 常量文本变体 = {...} 常量主页 = () => { 返回 ( ... 在我的 Home.js 中,我有以下代码 import React from 'react'; import './Home.css'; const textVariants = {...} const Home = () => { return ( <div id='home' className='page'> <motion.div className='text-wrapper' variants={textVariants} initial='initial' animate='animate'> <motion.div className='text-container' variants={textVariants}> <motion.h1 variants={textVariants}>NAME</motion.h1> <motion.h2 variants={textVariants}>An enthusiatic university student</motion.h2> </motion.div> </div> ); }; export default Home; 在 Home.css 中, .text-wrapper { max-width: 1366px; height: 100%; } .text-container { height: 100%; width: 50%; padding-left: 10%; h1 { letter-spacing: 10px; font-size: 50px; margin-bottom: -5%; } h2 { font-size: 80px; } } 我有 About.js 和 About.css 以及以下内容, import './About.css'; const About = () => { return ( <div id='about' className='page'> <div className='text-container'> <h1>About Me</h1> </div> </div> ); }; 但是 About.js 应用了 Home.css 中的内容,即 .text-container。我该如何避免这种情况?我不知道为什么 Home.css 被应用到 About.js 即使我没有导入它。 在React js中,任何根组件中导入的css文件适用于整个项目。 css 类可以在项目层次结构中的任何位置访问。 我们无法避免这种情况,因为文件被应用于根目录。您必须为不同的组件使用特定的类名称。 专业提示:创建可重用的组件,以便您可以将相同的类应用于每个相同的组件..


如何选择两个td并用bs4作为单行输出?

我想获取一些数据,但我很难选择两个 td 并将输出放在它们所属的同一行上。 HTML 示例: ፳ 我想获取一些数据,但我很难选择两个td并将输出放在它们所属的同一行。 HTML 示例: <tr> <td class ='verseNumCell'> ፳ </td> <td class ='verseConentCell'> ወትቤሎን ኢትስምያኒ ኖሔሚን ስምያኒ መራር እስመ መረርኩ ፈድፋደ ወብዙኀ ። </td> </tr> <tr> <td class ='verseNumCell'> ፳፩ </td> <td class ='verseConentCell'> አንሰ ምልእትየ ሖርኩ ወዕራቅየ አግብአኒ <span class='divineWord'>እግዚአብሔር</span> ለምንት ትብላኒ ኖሔሚን እንዘ <span class='divineWord'>እግዚአብሔር</span> አኅሰረኒ ወፈድፋደ አሕመመኒ ። </td> </tr> <tr> 我做了什么: import bs4 import requests import re url = "https://www.ethiopicbible.com/books/%E1%8A%A6%E1%88%AA%E1%89%B5-%E1%8B%98%E1%8D%8D%E1%8C%A5%E1%88%A8%E1%89%B5-1" parameters = {} response = requests.get(url, params=parameters) soup = bs4.BeautifulSoup(response.text, "html.parser") element_list = soup.find("div", class_="geezBibleChapterContainer").find_all("td") for element in element_list: text = element.get_text() text = os.linesep.join([s for s in text.splitlines() if s]) if not re.match(r'^\s*$', text): print(text) 我的输出: ፳ ወትቤሎን ኢትስምያኒ ኖሔሚን ስምያኒ መራር እስመ መረርኩ ፈድፋደ ወብዙኀ ። ፳፩ አንሰ ምልእትየ ሖርኩ ወዕራቅየ አግብአኒ እግዚአብሔር</span> ለምንት ትብላኒ ኖሔሚን እንዘ 我想得到什么: ፳ ወትቤሎን ኢትስምያኒ ኖሔሚን ስምያኒ መራር እስመ መረርኩ ፈድፋደ ወብዙኀ ። ፳፩ አንሰ ምልእትየ ሖርኩ ወዕራቅየ አግብአኒ እግዚአብሔር</span> ለምንት ትብላኒ ኖሔሚን እንዘ 我应该在单独的“汤”中选择 td 吗? 无需选择单元格,只需选择每一行并使用 get_text(separator=' ',strip=True): for row in soup.select('div.geezBibleChapterContainer tr'): print(row.get_text(' ',strip=True)) 什么导致: ፩ በቀዳሚ ገብረ እግዚአብሔር ሰማየ ወምድረ ። ፪ ወምድርሰ ኢታስተርኢ ወኢኮነት ድሉተ ወጽልመት መልዕልተ ቀላይ ወመንፈሰ እግዚአብሔር ይጼልል መልዕልተ ማይ ። ፫ ወይቤ እግዚአብሔር ለይኩን ብርሃን ወኮነ ብርሃን ። ፬ ወርእዮ እግዚአብሔር ለብርሃን ከመ ሠናይ ወፈለጠ እግዚአብሔር ማእከለ ብርሃን ወማእከለ ጽልመት ። ፭ ወሰመዮ እግዚአብሔር ለብርሃን ዕለተ ወለጽልመት ሌሊተ ወኮነ ሌሊተ ወጸብሐ ወኮነ መዓልተ ፩ ። ፮ ወይቤ እግዚአብሔር ለይኩን ጠፈር ማእከለ ማይ ከመ ይፍልጥ ማእከለ ማይ ወኮነ ከማሁ ። ፯ ወገብረ እግዚአብሔር ጠፈረ ወፈለጠ እግዚአብሔር ማእከለ ማይ ዘታሕተ ጠፈር ወማእከለ ማይ ዘመልዕልተ ጠፈር ። ፰ ወሰመዮ እግዚአብሔር ለውእቱ ጠፈር ሰማየ ወርእየ እግዚአብሔር ከመ ሠናይ ወኮነ ሌሊተ ወጸብሐ ወኮነ ካልእተ ዕለተ ። 示例 import requests import bs4 url = "https://www.ethiopicbible.com/books/%E1%8A%A6%E1%88%AA%E1%89%B5-%E1%8B%98%E1%8D%8D%E1%8C%A5%E1%88%A8%E1%89%B5-1" parameters = {} response = requests.get(url, params=parameters) soup = bs4.BeautifulSoup(response.text, "html.parser") for row in soup.select('div.geezBibleChapterContainer tr'): print(row.get_text(separator=' ',strip=True))


为什么这段代码能够判断二维数组中的数字是否重复?

//检查数独解法的有效性 bool validCheck (int sudoku [25][25], int n, int sqrt_n) { //检查行有效性 对于 (int i=0; i //checking validity of sudoku solution bool validityCheck (int sudoku [25][25], int n, int sqrt_n) { //checking rows validity for (int i=0; i<n; ++i) { // i means place in column bool numCounter [25] = { false }; for (int j=0; j<n; j++){ //j means place in row if (numCounter[(sudoku[i][j])-1] == true){ return false; } else { numCounter[(sudoku[i][j]) -1] = true; } } } //checking columns validity for (int j=0; j<n; ++j) { bool numCounter [25] = {false}; for (int i = 0; i<n; ++i){ if (numCounter[sudoku[i][j]-1] == true){ return false; } else { numCounter[sudoku[i][j]-1]=true; } } } //checking square validity for (int s = 0; s < sqrt_n; s++) { //s means square in column for (int r = 0; r < sqrt_n; r++) {//r means square in row bool numCounter [25] = {false}; int j = sqrt_n * s; for ( ; j < sqrt_n; ++j) { int i = sqrt_n * r; for ( ; i < sqrt_n; ++i){ if (numCounter[sudoku[i][j]-1] == true){ return false; } else { numCounter[sudoku[i][j]-1]=true; } } } } } return true; } 大家好,这段代码使用 bool 来判断一个数字是否在二维数组的行、列或平方根中重复。 是不是一开始bool被设置为false,如果假设值4被重复,那么首先它变成true,然后再次检查并发现它是true,所以我们知道它已经被重复并返回false? 我想我明白了,只是确定一下。 基本上,它有一个包含从1到26的所有号码的清单,检查该号码是否已被使用,如果没有则写入它。 因此,numCounter 是一个包含 25 个布尔值的数组,因为每行只有 25 个数字(1 到 26)。 数组中的每个布尔值都指示索引处的数字是否已被使用。 所以线条 if (numCounter[(sudoku[i][j])-1] == true){ return false; } else { numCounter[(sudoku[i][j]) -1] = true; } 首先检查该数字是否已被使用,如果有,则返回函数一个 false,表示数独不正确;如果不是,则通过将 bool 值设置为 true 来将其设置为已使用的。 在这种情况下,该行 sudoku[i][j] 返回数组数独中实际行位置 (j) 的实际列 (i) 中的数字。这应该给你一个 1 到 26 之间的数字。然后你输入 -1,因为数组从 0 而不是 1 开始。


标识符“ChatFeed”已被声明

从 'react-chat-engine' 导入 { ChatEngine, ChatFeed }; 从 './components/chatFeed' 导入 ChatFeed; 导入'./App.css'; 常量应用程序 = () => { 返回( import { ChatEngine, ChatFeed } from 'react-chat-engine'; import ChatFeed from './components/chatFeed'; import './App.css'; const App = () => { return( <ChatEngine height="100vh" projectID="" userName="" userSecret="" renderChatFeed={(chatAppProps) => <ChatFeed {...chatAppProps} />} /> ); } export default App; 服务器运行时显示错误 SyntaxError: D:\PROJECTS\APPLICATION\chat_app\src\App.js: Identifier 'ChatFeed' has already been declared. (3:7) 1 | import { ChatEngine, ChatFeed } from 'react-chat-engine'; 2 | > 3 | import ChatFeed from './components/chatFeed'; | ^ 好吧,错误消息说明了一切,您声明了 ChatFeed 两次。 您可以通过以下方式修复它: 重命名您的组件,例如 import ChatFeedComponent from './components/chatFeed'; 将命名导入从 react-chat-engine 重命名为 import { ChatEngine, ChatFeed as ChatFeedComp } from 'react-chat-engine'; 当然,随意使用你喜欢的任何名称 错误消息显示您导入 ChatFeed 两次。 您可以修复它,从第一行删除 chatFeed 用这个 从“react-chat-engine”导入{ChatEngine}; 从 './components/ChatFeed' 导入 ChatFeed;


在仪表针中设置弹出框(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>


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

我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户观看 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>


在 WPF 中绑定数据值

我正在通过数据绑定来绑定文本框的数据。而不是像这样给出最小值和最大值: 我正在通过数据绑定绑定文本框的数据。而不是像这样给出最小值和最大值: <TextBox Height="24" HorizontalAlignment="Right" abc:TextBoxMaskBehaviour.Mask="Decimal" abc:TextBoxMaskBehaviour.MinimumValue="0" abc:TextBoxMaskBehaviour.MaximumValue="200" Margin="0,9,8.5,0" Name="txtCStart" VerticalAlignment="Top" Width="106" MouseWheel="OnMouseWheel"> 我想通过 .xaml.cs 文件给出它。如何做到这一点? 显然(从你的评论来看,你的问题不是很清楚),你想通过C#代码设置abc:TextBoxMaskBehaviour.MinimumValue和MaximumValue: TextBoxMaskBehaviour.SetMinimumValue(txtCStart, 0); TextBoxMaskBehaviour.SetMaximumValue(txtCStart, 200); 一般来说,您可以像这样设置附加属性:AttachedPropertyClass.SetAttachedProperty(Control, Value)。同样,可以使用 AttachedPropertyClass.GetAttachedProperty(Control). 读取该值。 这看起来可能与 Rubenhak TextBoxMask 功能直接相关(因此我发现它想要回答这个确切的问题)。对于任何关注鲁本哈克的人来说,答案是: Rubenhak.Common.WPF.TextBoxMaskBehavior.SetMask( TextBoxControl, Rubenhak.Common.WPF.MaskType.Decimal); 同样适用于: Rubenhak.Common.WPF.TextBoxMaskBehavior.SetMinimumValue() Rubenhak.Common.WPF.TextBoxMaskBehavior.SetMaximumValue()


按照路径流对 svg 填充进行动画处理

我有以下SVG;它类似于字母“P”。我想用黑色填充整个“P”,但要逐渐地遵循绘图的流程,就像正在绘制一样。 我有以下SVG;它类似于字母“P”。我想用黑色填充整个“P”,但要逐渐地遵循绘图的流程,就像正在绘制一样。 <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <g stroke="#000" stroke-width="1" fill="none"> <path d="M31.5294 14.2118C31.5294 18.8819 28.7623 22.9082 24.7793 24.7351C26.4612 23.3496 27.5322 21.248 27.5322 18.896C27.5322 14.7642 24.2259 11.4042 20.112 11.3205C20.0574 11.3167 20.0075 11.3167 19.9529 11.3167C19.8983 11.3167 19.8485 11.3167 19.7939 11.3205C18.2673 11.4033 17.0588 12.6663 17.0588 14.2108V28.6814C17.0588 33.4748 13.1699 37.3638 8.37646 37.3638V14.2118C8.37646 7.81928 13.5605 2.63528 19.9529 2.63528C26.3454 2.63528 31.5294 7.81928 31.5294 14.2118Z"/> </g> </svg> 如果我只是从下到上或从左到右填充,其他类似问题的解决方案,它不会遵循绘制时的“P”形状。请注意:我对 SVG 没有太多专业知识。 我举了一个例子来说明如何做到这一点。我知道这可能不完全是您想要的,但这说明了一条可以遵循的道路。 <!DOCTYPE html> <html lang="en"> <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> <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <style> @keyframes fade-in-right { from { clip-path: circle(0px); } to { clip-path: circle(40px); } } #path2 { animation: fade-in-right ease 4s infinite; } </style> <g stroke="#000000" stroke-width="1" fill="none" id="g1"> <path d="m 31.5294,14.2118 c 0,4.6701 -2.7671,8.6964 -6.7501,10.5233 1.6819,-1.3855 2.7529,-3.4871 2.7529,-5.8391 0,-4.1318 -3.3063,-7.4918 -7.4202,-7.5755 -0.0546,-0.0038 -0.1045,-0.0038 -0.1591,-0.0038 -0.0546,0 -0.1044,0 -0.159,0.0038 -1.5266,0.0828 -2.7351,1.3458 -2.7351,2.8903 v 14.4706 c 0,4.7934 -3.8889,8.6824 -8.68234,8.6824 v -23.152 c 0,-6.39252 5.18404,-11.57652 11.57644,-11.57652 6.3925,0 11.5765,5.184 11.5765,11.57652 z" id="path1" /> </g> <g stroke="#000000" stroke-width="1" fill="none" id="g2"> <path d="m 31.5294,14.2118 c 0,4.6701 -2.7671,8.6964 -6.7501,10.5233 1.6819,-1.3855 2.7529,-3.4871 2.7529,-5.8391 0,-4.1318 -3.3063,-7.4918 -7.4202,-7.5755 -0.0546,-0.0038 -0.1045,-0.0038 -0.1591,-0.0038 -0.0546,0 -0.1044,0 -0.159,0.0038 -1.5266,0.0828 -2.7351,1.3458 -2.7351,2.8903 v 14.4706 c 0,4.7934 -3.8889,8.6824 -8.68234,8.6824 v -23.152 c 0,-6.39252 5.18404,-11.57652 11.57644,-11.57652 6.3925,0 11.5765,5.184 11.5765,11.57652 z" id="path2" style="fill:#000000;fill-opacity:1;stroke:none" /> </g> </svg> </body> </html>


从数据库中选择 SELECT 选项后如何显示/隐藏 DIV?

这是选择选项的代码; 这是选择选项的代码; <div class="modal-body row"> <form role="form" action="patient/addNew" class="clearfix" method="post" enctype="multipart/form-data"> <div class="form-group col-md-6"> <label for="exampleInputEmail1"><?php echo lang('categorie'); ?></label> <select class="form-control m-bot15" name="categorie" value='' id="p_category"> <option value="#"> Sélectionner catégorie</option> <?php foreach ($categories as $category) { ?> <option value="category"><?php if (!empty($setval)) { if ($category->category == set_value('category')) { echo 'selected'; } } if (!empty($patient->category)) { if ($category->category == $patient->category) { echo 'selected'; } } ?> > <?php echo $category->category; ?> </option> <?php } ?> </select> </div> 这是必须显示/隐藏的 div: <label for="exampleInputEmail1"><?php echo lang('name_Us'); ?></label> <input type="text" class="form-control" name="name_husband" id="nameUs" placeholder=""> <label for="exampleInputEmail1"><?php echo lang('number_pre'); ?></label> <input type="number" class="form-control" name="number_pre" id="nbreEnf" placeholder=""> </div> 这是 JavaScript 代码: $('.divUs').hide(); $(document.body).on('change', '#p_category', function () { var v = $("select.p_category option:selected").val() if (v == 'Fe_Ence') { $('.divUs').show(); } else { $('.divUs').hide(); } }); }); 我希望如果选择了元素(Fe_Ence),则可以显示 div,否则,它保持隐藏 例如,您可以使用 :has 选择器 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="thingtohide"> <h1>Hello</h1> </div> <div id="checkbox"> <input type="checkbox"> </div> <style> body:has(#checkbox input:checked) #thingtohide { visibility: hidden; } </style> </body> </html> 因此,如果父元素有一个选中的复选框,那么您可以定位与该父元素不同的子元素。


表单响应:“无法处理请求 HTTP ERROR 500”。我做错了什么?

我尝试在网站上编写 php 表单,但收到错误 500。我无法弄清楚我做错了什么。你能看一下代码看看我做错了什么吗? PHP: 我尝试在网站上编写 php 表单,但收到错误 500。我无法弄清楚我做错了什么。你能看一下代码看看我做错了什么吗? PHP: <?php // define variables and set to empty values $name = $email = $phone = $enquiry = ""; if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" ) { if ( empty( $_POST[ "name" ] ) ) { $nameErr = "Name is required"; } else { $name = test_input( $_POST[ "name" ] ); // check if name only contains letters and whitespace if ( !preg_match( "/^[a-zA-Z-' ]*$/", $name ) ) { $nameErr = "Only letters and white space allowed"; } } if ( empty( $_POST[ "email" ] ) ) { $emailErr = "Email is required"; } else { $email = test_input( $_POST[ "email" ] ); // check if e-mail address is well-formed if ( !filter_var( $email, FILTER_VALIDATE_EMAIL ) ) { $emailErr = "Invalid email format"; } } if ( empty( $_POST[ "phone" ] ) ) { $comment = ""; } else { $comment = test_input( $_POST[ "phone" ] ); } if ( empty( $_POST[ "enquiry" ] ) ) { $comment = ""; } else { $comment = test_input( $_POST[ "enquiry" ] ); } } // Create the email and send the message $destination = "[email protected]"; $subject = "Website Contact Form Enquiry: $name"; $body = "You have received a new message from your website contact form.\\n\\n"."Here are the details:\\n\\nName: $name\\n\\nEmail: $email\\n\\nPhone: $phone\\n\\nEnquiry:\\n$enquiry"; $header = "From: [email protected]\\n"; $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: " . $fromAddress; $headers[] = "Subject: " . $subject; $headers[] = "X-Mailer: PHP/".phpversion(); mail($destination, $subject, $message, implode("\r\n", $headers)); // mail($to,$subject,$msg,$headers); echo "Email successfully sent."; ?> HTML 格式: <form id="contact-form" method="post" action="/contact.php" role="form"> <div class="messages"></div> <div class="controls"> <div class="row"> <div class="col-md-10"> <div class="form-group"> <input id="form_name" type="text" name="name" class="form-control" placeholder="Name*" required="required" data-error="Your name is required." > <div class="help-block with-errors"></div> </div> </div> <div class="col-md-10"> <div class="form-group"> <input id="form_email" type="email" name="email" class="form-control" placeholder="Email*" required="required" data-error="Valid email is required." > <div class="help-block with-errors"></div> </div> </div> <div class="col-md-10"> <div class="form-group"> <input id="form_phone" type="text" name="phone" class="form-control" placeholder="Phone" > <div class="help-block with-errors"></div> </div> </div> </div> <div class="row"> <div class="col-md-10"> <div class="form-group"> <textarea id="form_enquiry" name="enquiry" class="form-control" placeholder="Enquiry*" rows="6" required="required" data-error="Please, leave us a message."></textarea> <div class="help-block with-errors"></div> </div> </div> <div class="col-md-12"> <input class="btn btn-large btn-primary centre mt-10" type="submit" value="Submit" > </div> </div> </div> </form> 我已按照其他人的指示使表单正常工作,但所做的更改仍然会出现错误。 这是一个简单的形式,但我似乎对我做错了什么缺乏了解。 请帮助我。 如果您查看发送邮件的行,这是一个硬行结尾,将 $headers 推到新行上吗?这将调用 500 错误。 查看 /var/log/apache2/error.log(如果您使用的是 Debian)或 /var/log/httpd/error.log(如果使用的是 RHEL 或类似系统)。 您的代码存在许多问题,但首先关注快乐的道路,然后让事情正常运行。


对于使用PHP的循环,我想使用PHP在数据库表中插入动态行,每行有10列

我有一个这样的数据库表 我想动态插入从 0000 到 0999 的数据,连续 10 个数据,如下所示 我正在尝试这样的事情 我有一个这样的数据库表 我想动态插入从 0000 到 0999 的数据,连续 10 个数据,如下所示 我正在尝试这样的事情 <?php for($i=0;$i<=999;$i++){ $num= str_pad($i, 4, "0", STR_PAD_LEFT); $x = 10; if ($i % $x == 0) { mysqli_query($con,"INSERT INTO `0000_0999` (`id`, `col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`) VALUES (NULL, '', '', '', '', '', '', '', '', '', '', '');") } } ?> 但我不知道如何传递列明智的数据。 您只需创建一个数组来保存每行的列值 对于每一行,您必须保存该列的值,您可以简单地创建一个数组来保存 并迭代循环并将数据插入数据库 使用此代码: for ($i = 0; $i <= 999; $i++) { $num = str_pad($i, 4, "0", STR_PAD_LEFT); // Create an array to hold column values for each row $rowData = array( 'col1' => '', 'col2' => '', 'col3' => '', 'col4' => '', 'col5' => '', 'col6' => '', 'col7' => '', 'col8' => '', 'col9' => '', 'col10' => '' ); // Convert the array values into a comma-separated string $values = "'" . implode("', '", $rowData) . "'"; // Your insert query $query = "INSERT INTO `0000_0999` (`id`, `col1`, `col2`, `col3`, `col4`, `col5`, `col6`, `col7`, `col8`, `col9`, `col10`, `col11`) VALUES (NULL, $values)";} 逐步解释 步骤 1 - 在此过程中,我创建了一个数组,并在该数组中设置了列值 步骤 2 - 我将数组值转换为字符串(逗号分隔) 第 3 步 - 插入值


如何使用 JS 延迟加载新的 Google Adsense 代码

谷歌已取代 <question vote="1"> <p>谷歌已取代 <br/></p> <p><pre><code>&lt;script async src=&#34;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&lt;/script&gt;</code></pre> <br/></p> <p>与<br/></p> <p><pre><code>&lt;script async src=&#34;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456&#34; crossorigin=&#34;anonymous&#34;&lt;/script&gt;</code></pre> <br/></p> <p><strong>参考</strong>:<a href="https://support.google.com/adsense/answer/10627874" rel="nofollow noreferrer">Google Adsense 公告</a><br/></p> <p><strong>旧的 Adsense 代码就像:</strong></p> <pre><code>&lt;script async src=&#34;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXX&#34; crossorigin=&#34;anonymous&#34;&gt;&lt;/script&gt; &lt;ins class=&#34;adsbygoogle&#34; style=&#34;display:inline-block;width:350px;height:90px&#34; data-ad-client=&#34;ca-pub-XXXXXXXXXXXXXXXX&#34; data-ad-slot=&#34;XXXXXXXXXX&#34;&gt;&lt;/ins&gt; &lt;script&gt; (adsbygoogle = window.adsbygoogle || []).push({}); &lt;/script&gt; </code></pre> <p><strong>新的 Adsense 代码如下:</strong></p> <pre><code>&lt;script async src=&#34;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXX&#34; crossorigin=&#34;anonymous&#34;&gt;&lt;/script&gt; &lt;ins class=&#34;adsbygoogle&#34; style=&#34;display:inline-block;width:350px;height:90px&#34; data-ad-client=&#34;ca-pub-XXXXXXXXXXXXXXXX&#34; data-ad-slot=&#34;XXXXXXXXXX&#34;&gt;&lt;/ins&gt; &lt;script&gt; (adsbygoogle = window.adsbygoogle || []).push({}); &lt;/script&gt; </code></pre> <p><strong>页面加载完成后加载广告的旧 JS 代码是:</strong></p> <pre><code> &lt;script type=&#34;text/javascript&#34;&gt; function downloadJSAtOnload() { var element = document.createElement(&#34;script&#34;); element.src = &#34;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&#34;; document.body.appendChild(element); } if (window.addEventListener) window.addEventListener(&#34;load&#34;, downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent(&#34;onload&#34;, downloadJSAtOnload); else window.onload = downloadJSAtOnload; &lt;/script&gt; </code></pre> <p>由于在新广告代码的脚本标签中添加了<pre><code>?client=ca-pub-xxxxxx&#34; crossorigin=&#34;anonymous&#34;</code></pre>,那么现在加载广告的新JS代码是什么?</p> </question> <answer tick="true" vote="1"> <p>嗯,这并不是真正的延迟加载,这是延迟加载,不推荐,但你就可以了</p> <pre><code>&lt;script&gt; function downloadJSAtOnload() { var element = document.createElement(&#34;script&#34;); element.src = &#34;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXXXXX&#34;; element.async = true; element.setAttribute(&#39;crossorigin&#39;, &#39;anonymous&#39;); document.body.appendChild(element); } if (window.addEventListener) window.addEventListener(&#34;load&#34;, downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent(&#34;onload&#34;, downloadJSAtOnload); else window.onload = downloadJSAtOnload; &lt;/script&gt; </code></pre> <p>如果您正在寻找延迟加载 AdSense,请查看 <a href="https://www.guest.blog/post/12068/lazy-loading-adsense-ads/" rel="nofollow noreferrer">延迟加载 Adsense</a></p> </answer> <answer tick="false" vote="0"> <blockquote> <h2>引用的标题##<script async</h2> <p>src="https://pagead2.googlesyndicate.com/pagead/js/adsbygoogle.js?client=ca-pub-1049121221402917" 跨桥=“匿名”></p> </blockquote> </answer> </body></html>


如何将 Div 布局转换为基于 CSS 样式的 HTML 表格?

我正在开发一个项目,需要使用 、、、 和 将使用 元素设计的复杂布局转换为 HTML 表格 我正在开发一个项目,需要将使用 <div> 元素设计的复杂布局转换为使用 <table>、<tr>、<td>、<colspan> 和 <rowspan> 标签的 HTML 表格。布局当前使用 CSS 进行样式设置,我希望在将其转换为表格格式时保留相同的结构和外观。 输入: 我有一系列 <div> 元素,以表格格式表示标题和数据单元格。每个 <div> 都有多个类属性,对应于定义其位置和大小的特定 CSS 样式。这是当前基于 div 的布局的片段: <div class="c x1b y41 wf h14">Project</div> <div class="c x20 y43 w10 h6">2023</div> <div class="c x21 y43 w11 h6">2022</div> <div class="c x23 y43 w12 h6">2021</div> <div class="c x1e y43 w13 h6">2020</div> <div class="c x20 y41 w14 h9">Amount</div> <div class="c x26 y41 w15 h9">Ratio</div> <div class="c x21 y41 w16 h9">Amount</div> <div class="c x28 y41 w17 h9">Ratio</div> <div class="c x23 y41 w18 h9">Amount</div> <div class="c x29 y41 w19 h9">Ratio</div> <div class="c x1e y41 w1a h9">Amount</div> <div class="c x2a y41 w1b h9">Ratio</div> <div class="c x1b y44 wf h6">Income</div> <div class="c x20 y44 w14 h6">9.6</div> <div class="c x26 y44 w15 h6">100.00</div> <div class="c x21 y44 w16 h6">377.78</div> <div class="c x28 y44 w17 h6">100.00</div> <div class="c x23 y44 w18 h6">293.47</div> <div class="c x29 y44 w19 h6">100.00</div> <div class="c x1e y44 w1a h6">210.66</div> <div class="c x2a y44 w1b h6">100.00</div> CSS 样式: 布局由这些 CSS 样式控制,它们规定了 div 的尺寸和位置: .h14 {height: 41.215200px;} .h6 {height: 20.280000px;} .h9 {height: 20.311200px;} .w10 {width: 116.095200px;} .w11 {width: 116.251200px;} .w12 {width: 116.376000px;} .w13 {width: 122.959200px;} .w14 {width: 55.099200px;} .w15 {width: 60.216000px;} .w16 {width: 58.188000px;} .w17 {width: 57.283200px;} .w18 {width: 61.152000px;} .w19 {width: 54.600000px;} .w1a {width: 61.963200px;} .w1b {width: 60.372000px;} .wf {width: 73.008000px;} .x1b {left: 112.450000px;} .x1e {left: 537.830800px;} .x20 {left: 186.914000px;} .x21 {left: 303.641000px;} .x23 {left: 420.511000px;} .x26 {left: 242.801000px;} .x28 {left: 362.609000px;} .x29 {left: 482.287000px;} .x2a {left: 600.262000px;} .y41 {bottom: 490.373000px;} .y43 {bottom: 511.303000px;} .y44 {bottom: 469.313000px;} 预期结果: 我想将此布局转换为 HTML 表格。预期的表结构应类似于以下内容: <table border="1"> <tr> <td rowspan="2">Project</td> <td colspan="2">2023</td> <td colspan="2">2022</td> <td colspan="2">2021</td> <td colspan="2">2020</td> </tr> <tr> <td>Amount</td> <td>Ratio</td> <td>Amount</td> <td>Ratio</td> <td>Amount</td> <td>Ratio</td> <td>Amount</td> <td>Ratio</td> </tr> <tr> <td>Income</td> <td>9.6</div></td> <td>100.00</td> <td>377.78</td> <td>100.00</td> <td>293.47</td> <td>100.00</td> <td>210.66</td> <td>100.00</td> </tr> </table> 尝试: 我尝试了多种方法来解析 div 并应用它们的样式来创建表格,但没有一种方法有效。我已经尝试使用 JavaScript 动态读取 CSS 属性并将它们作为属性应用到表格单元格,但我在维护布局完整性方面遇到了问题,尤其是在跨越行和列时。 问题: 任何人都可以提供有关如何考虑 CSS 样式以编程方式将这种基于 div 的布局转换为 HTML 表格的指导或解决方案吗?如果您能帮助解析 CSS 以定义表中适当的 <colspan> 和 <rowspan> 值,我们将不胜感激。 如果您只想让它看起来像表格而不是语义。您可以尝试使用网格和固定数量的列来执行此操作,例如使用grid-template-columns: repeat(10, 1fr)。


从数据库表中选择选择选项后如何显示/隐藏隐藏的 Div?

以下是选择选项的代码: 这是选择选项的代码: <div class="modal-body row"> <form role="form" action="patient/addNew" class="clearfix" method="post" enctype="multipart/form-data"> <div class="form-group col-md-6"> <label for="exampleInputEmail1"><?php echo lang('categorie'); ?></label> <select class="form-control m-bot15" name="categorie" value='' id="p_category"> <option value="#"> Sélectionner catégorie</option> <?php foreach ($categories as $category) { ?> <option value="category"><?php if (!empty($setval)) { if ($category->category == set_value('category')) { echo 'selected'; } } if (!empty($patient->category)) { if ($category->category == $patient->category) { echo 'selected'; } } ?> > <?php echo $category->category; ?> </option> <?php } ?> </select> </div> 这是应该显示/隐藏的 Div: <div class="form-group col-md-6" id="divCacher" style="display: none"> <label for="exampleInputEmail1"><?php echo lang('name_husband'); ?></label> <input type="text" class="form-control" name="name_Us" id="nameUs" placeholder=""> <label for="exampleInputEmail1"><?php echo lang('number_pregnancy'); ?></label> <input type="number" class="form-control" name="number_pregnancy" id="nbreEnfants" placeholder=""> </div> 这是 JavaScript 代码: $(document).ready(function () { $('.divCacher').hide(); $(document.body).on('change', '#p_category', function () { var v = $("select.p_category option:selected").val() if (v == 'Fe_Ence') { $('.divCacher').show(); } else { $('.divCacher').hide(); } }); }); 我希望如果我们选择 Fe_Ence 类别,则 div 会显示,否则,它会保持隐藏 您需要将 $category 设置为选项值更改此: <option value="category"> 对此: <option value="<?=$category?>"> 以下是适用于更多此类情况的示例: <!--SELECT INPUT--> <select id="p_category"> <option value=""> Sélectionner catégorie</option> <?php foreach ($categories as $category): ?> <option value="<?=$category?>"><?=$category?> <?php endforeach;?> </select> <!--Container List--> <div class="cat-container" data-id="test1"> <h1>This is Test1 Category</h1> </div> <div class="cat-container" data-id="Fe_Ence"> <h1>This is Fe_Ence Category</h1> </div> <div class="cat-container" data-id="test3"> <h1>This is test3 Category</h1> </div> // Javascript code checkCategory(); $("#p_category").on('change', checkCategory) function checkCategory() { $('.cat-container').hide() const selected = $('#p_category').val() if (!selected) return; $(`[data-id=${selected}`).show() }


XSL/XSLT - 动态获取父节点及其值

有人可以帮助我吗?我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 例子: 有人可以帮助我吗?我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 示例: <?xml version="1.0" encoding="utf-8"?> <Data totalExecutionTime="00:00:00.0076034" totalCount="1">   <Features>     <ProductID id="100" language="NLB" caption="Product ID" captionAlternative="Product ID" unit="" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="" viewGroup="" viewGroupOrder="0" topViewGroupId="b65b432a-1bf1-4fd4-ae92-03418d3204be" topViewGroup="Algemeen" topViewGroupOrder="1" viewOrder="0" form="Complex" dataType="String" readOnly="False" />     <Length id="245" language="NLB" caption="Lengte" captionAlternative="Lengte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="1" form="Simple" dataType="Number" readOnly="False" />     <Width id="242" language="NLB" caption="Breedte" captionAlternative="Breedte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="2" form="Simple" dataType="Number" readOnly="False" />     <Height id="244" language="NLB" caption="Hoogte" captionAlternative="Hoogte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="3" form="Simple" dataType="Number" readOnly="False" />     <Depth id="771" language="NLB" caption="Diepte" captionAlternative="Diepte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="4" form="Simple" dataType="Number" readOnly="False" />     <Weight id="243" language="NLB" caption="Gewicht" captionAlternative="Gewicht" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="5" form="Simple" dataType="Number" readOnly="False" />     <LoadCapacity id="457" language="NLB" caption="Draagvermogen" captionAlternative="Draagvermogen" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="6" form="Simple" dataType="Number" readOnly="False" />     <Volume id="435" language="NLB" caption="Inhoud" captionAlternative="Inhoud" unit="l" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="bfaf678b-8b9d-4cea-aa99-08edd8316dc7" viewGroup="Algemene specificaties" viewGroupOrder="13" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="7" form="Simple" dataType="Number" readOnly="False" />     <TireSize id="705" language="NLB" caption="Banden maat" captionAlternative="Banden maat" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="8" form="Simple" dataType="String" readOnly="False" />     <LoadingScoop id="706" language="NLB" caption="Laadschep" captionAlternative="Laadschep" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="9" form="Simple" dataType="String" readOnly="False" />   </Features>   <ProductID id="25137" parentId="0" brand="Normal" order="0" createdDate="2020-03-24T15:30:07.21" modifiedDate="2023-11-20T20:01:33.87">     <Value seq="0" modifiedDate="2020-03-24T15:30:10.493">111TA5851</Value>     <Width seq="0" modifiedDate="2020-03-24T15:30:10.493">515</Width>     <Height seq="0" modifiedDate="2020-03-24T15:30:10.493">1100</Height>     <Weight seq="0" modifiedDate="2020-04-02T13:18:09.44">7.7</Weight>     <LoadCapacity seq="0" modifiedDate="2020-03-24T15:30:10.493">150</LoadCapacity>     <LoadingScoop seq="0" modifiedDate="2020-03-24T15:30:10.493">350x170</LoadingScoop>   </ProductID> </Data> 我想要的是动态获取对应父节点的值。我可以获得如下节点名称: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="/Data/ProductID/*"> <xsl:variable name="myVariable" select="name(.)"/> <xsl:variable name="HasValue" select="count(/Data/ProductID/*)" /> <tr> <td><xsl:value-of select="name(.)" /></td> <td><xsl:value-of select="local-name()" /></td> <td><xsl:value-of select="name()" /></td> <td><xsl:value-of select="/Data/node($myVariable)/@unit" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> 但我不知道如何获取响应的父节点及其值,例如单位元素。 提前致谢并致以诚挚的问候 我已经尝试过但没用。我会不断收到错误:解析 '' 期间出现意外的标记 '$myVariable'。 我想你想声明一把钥匙 <xsl:key name="element-key" match="Data/Features" use="name()"/> 然后你想使用例如key('element-name', name())/@unit。


引导进度条没有进度

引导进度条在我的 MVC 索引视图上不起作用。 我已经用 Chrome 和 Internet Explorer 尝试过了。 @{ ViewBag.Title = "首页"; } 引导进度条在我的 MVC 索引视图上不起作用。 我已经用 Chrome 和 Internet Explorer 尝试过了。 @{ ViewBag.Title = "Home Page"; } <div class="jumbotron"> <h1>ASP.NET</h1> <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p> <p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more &raquo;</a></p> </div> <div class="row"> <div class="col-md-4"> <h2>Getting started</h2> <div class="progress-bar progress-striped "></div> </div> </div> 本次聚会迟到了,但在我使用的 Bootstrap 版本(v3.1.1)中,该类是“progress-striped”(不是像文档所说的“progress-bar-striped”),并且它和“active” ' 类必须应用于外部 div: <div class="progress progress-striped active"> <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">Some text</div> </div> 查看 CSS,选择器“progress-bar”已更改为“bar”: ./bootstrap.css: .progress { ... } .progress .bar { ... } 因此,将您的代码更改为 <div class="progress"> <div class="bar"> </div> </div> 然后就可以了。 不确定这种疯狂的原因是什么,似乎引导文档还没有更新。 <div class="progress"> <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div> </div> 这样进度动画就可以工作了。 <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;"> <span class="sr-only">60% Complete</span> </div> </div> 上面是 bootstrap v3.1.1 的代码,看起来你的进度条 div 缺少一些元素? 如果您使用 Bootstrap v4 并且需要动画,则需要使用 progress-bar-animated 而不是 active。


ng-bootstrap 滚动间谍在没有高度的情况下无法工作?

我在我的项目中使用 ng-bootstrap [ngbScrollSpy] 指令,如文档中所述,但它不起作用 - 滚动时活动项目不会改变。 我的代码如下: 我在我的项目中使用 ng-bootstrap [ngbScrollSpy] 指令,如文档中所述,但它不起作用 - 滚动时活动项目不会改变。 我的代码如下: <div> <div class="sticky-top"> <ul class="nav menu-sidebar"> <li > <a [ngbScrollSpyItem]="[spy, 'about']">About</a> </li> <li > <a [ngbScrollSpyItem]="spy" fragment="schedule">Schedule</a> </li> <li > <a [ngbScrollSpyItem]="spy" fragment="hotel">Information about the hotel</a> </li> </ul> </div> <div ngbScrollSpy #spy="ngbScrollSpy" > <section ngbScrollSpyFragment="about"> <h3>About</h3> <p>{{some long long text and content}}</p> </section> <section ngbScrollSpyFragment="schedule"> <h3>Schedule</h3> <p>{{some long long text and content}}</p> </section> <section ngbScrollSpyFragment="hotel"> <h3>Information about the hotel</h3> <p>{{some long long text and content}}</p> </section> </div> </div> 我在这个 stackoverflow 问题中看到,我的问题是我没有向我的 div 提供 height,这是事实。 但我的滚动间谍部分遍布整个页面,而不是一个小 div,(导航本身是 sticky-top)。所以我不能给它高度。 我知道有替代方法 - 刷新窗口滚动上的滚动间谍,但我没有找到可以帮助我的正确代码。 你能解决我的问题吗? 为我提供刷新滚动间谍的代码/给我有关高度的提示/帮助我找到另一个相应的元素。 非常感谢! 附上 stackblitz 演示的链接 注意:我使用来自 @ng-bootstrap/ng-bootstrap 的 NgbScrollSpy (我想它是非常相似的库) 我做什么: 我将所有内容(包括导航)包装在中 <div class="wrapper" ngbScrollSpy #spy="ngbScrollSpy" rootMargin="2px" [threshold]="1.0" > <div class="sticky-top pt-4 pb-4 bg-white"> ..here the navigation... </div> ..here the sections... <section ngbScrollSpyFragment="about"> </section> //the last I use margin-bottom:2rem; <section ngbScrollSpyFragment="hotel" style="margin-bottom:10rem" </section> </div> 见“门槛”。这表明“更改”活动片段应该可见的百分比(1 是 100%) 包装类 .wrapper{ height:100%; position: absolute; top:0; } 我使用强制链接的类别 //remove all the class for the link a{ color:black; text-decoration:none; padding:8px 16px; } a.custom-active{ color:white; background-color:royalblue } 以及我使用的每个链接 <a [class.custom-active]="spy.active=='about'">About</a> 嗯,问题是如何“滚动到”。 “链接”应该作为链接使用。 第一个是指示“路由器”应该考虑“碎片” 如果我们的组件是独立组件,我们需要使用提供者,provideRouter bootstrapApplication(App, { providers: [ provideRouter([], withInMemoryScrolling({anchorScrolling:'enabled'})), ] }) 然后,我们需要考虑到我们的页面确实没有滚动,div“包装器”是谁拥有滚动。因此,我们订阅 router.events,当事件有“锚点”时,我们滚动“包装器”div constructor(router: Router) { router.events.pipe(filter((e:any) => e.anchor)).subscribe((e: any) => { (document.getElementById('wrapper') as any).scrollTop+= (document.getElementById(e.anchor)?.getBoundingClientRect().top||0) -72; //<--this is the offset }); } 在这个stactblitz中你有一个有效的例子


带有边框半径和粘性标题的 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


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