简体   繁体   English

如何在连接到 sql 的反应表 crud 中添加 2 个箭头,一个顶部箭头按钮和一个底部箭头按钮?

[英]How do I add add 2 arrow each, one top arrow button and one bottom arrow button to my react table crud connected to my sql?

body characters at least 30 chars正文字符至少 30 个字符

You can create an icon and then transform: rotate it using a class.您可以创建一个图标然后transform: rotate它。 Then set you elements items using positioning .然后使用定位设置元素项。

Embed the icons in the parent element and then set the parent to position: relative then on the arrows, set their position:absolute and then set their left and top positions relative to the parent element.将图标嵌入到父元素中,然后将父元素设置为position: relative然后在箭头上,设置它们的position:absolute然后设置它们对于父元素的左侧顶部位置

For the JS, use a loop on the arrow class and then check classList for up or down , use the event.target to get the element being clicked.对于 JS,在箭头 class 上使用循环,然后检查classListupdown ,使用event.target获取被点击的元素。

I use a dataset on the parentNode to show that the event.target is working.我使用parentNode上的数据集来显示event.target正在工作。

 const arrows = document.querySelectorAll('.arrow') function upDown(e) { if (e.target.classList.contains('up')) { console.log('up', e.target.parentNode.dataset.id) } if (e.target.classList.contains('down')) { console.log('down', e.target.parentNode.dataset.id) } } arrows.forEach(arrow => { arrow.addEventListener('click', upDown) })
 body { margin: 0; padding:0; } table { width: 100vw; } th { border: solid 2px black; padding-left: 1rem; position: relative; font-family: sans-serif; } th:nth-of-type(2){ width: 9rem; }.arrow { border: solid black; border-width: 0 2.5px 2.5px 0; display: inline-block; padding: 2.5px; }.up { transform: rotate(-135deg); -webkit-transform: rotate(-135deg); position: absolute; left: 9rem; top: .2rem; cursor: pointer; }.up:hover { border: solid red; border-width: 0 2px 2px 0; display: inline-block; padding: 2.5px; }.down { transform: rotate(45deg); -webkit-transform: rotate(45deg); position: absolute; left: 9rem; bottom: .2rem; cursor: pointer; }.down:hover { border: solid red; border-width: 0 2.5px 2.5px 0; display: inline-block; padding: 2.5px; }
 <table> <tr> <th>Contact 1 info: John Doe</th> <th class="cont" data-id="John Doe">Contacted 1 <i class="arrow up"></i> <i class="arrow down"></i> </th> </tr> </table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在jQuery中一键单击按钮(上一页/下一页)或箭头来滑动我的内容? - how to slide my content one by one clicking button(prev/next) or arrow in jquery? 如何在我的画布线上添加矩形/箭头? - How to add rectangle/arrow to my canvas line? 将弹跳滚动箭头添加到我的网页底部? - Add bouncing scroll arrow to bottom of my web page? 如何实现 function 以使用箭头键浏览我的反应表? - How do I implement a function to navigate through my react table using arrow keys? 如何在我的jQuery图像和文本滑块中添加左/右箭头(下一个/上一个)功能? - How do I add Left/Right Arrow (Next/Previous) functionality to my jQuery image and text slider? 如何在我的箭头 function 中添加 if、else if、else 条件,其中已经包含.map 和.filter? - How do I add an if , else if, else condition to my arrow function which includes .map and .filter already? 如何让我的 Phaser 游戏射出不止一支箭? - How do I make my Phaser game shoot more than one arrow? 将箭头向下添加到半径按钮 - Add arrow down css to the radius button 如何在标题的底部使箭头向上? - how can I make an arrow point upwards at the bottom of my header? 如何在按钮中的向下箭头和向上箭头之间切换? - How can I change between arrow down and arrow up in a button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM