使用样式化组件使元素可选项卡
Making an element tabbable with Styled Components
我希望人们能够 "focus" 在我的 div 选项卡上。到目前为止我试过这个:
const Div = styled.div.attrs({
tabindex: '0',
})`
margin: auto;
width: 100%;
max-width: 1200px;
height: 320px;
background: url(${({ rtl }) => determineUrl(rtl)}) no-repeat center;
display: grid;
grid-template-columns: 100%;
grid-template-rows: 100%;
@media (min-width: ${resolutions.min.mobile}px) and (max-width: ${resolutions.max.mobile}px){
max-height: 240px;
}
`;
还有这个:
<Div tabindex={0}>...</Div>
以及
<Div tabindex={"0"}>...</Div>
这些都不行,也想不出别的了
tabindex
在 React 中是无效的 属性 名称,它应该是 tabIndex
并且它只接受数字作为值,所以 tabIndex={0}
应该可以解决问题
我希望人们能够 "focus" 在我的 div 选项卡上。到目前为止我试过这个:
const Div = styled.div.attrs({
tabindex: '0',
})`
margin: auto;
width: 100%;
max-width: 1200px;
height: 320px;
background: url(${({ rtl }) => determineUrl(rtl)}) no-repeat center;
display: grid;
grid-template-columns: 100%;
grid-template-rows: 100%;
@media (min-width: ${resolutions.min.mobile}px) and (max-width: ${resolutions.max.mobile}px){
max-height: 240px;
}
`;
还有这个:
<Div tabindex={0}>...</Div>
以及
<Div tabindex={"0"}>...</Div>
这些都不行,也想不出别的了
tabindex
在 React 中是无效的 属性 名称,它应该是 tabIndex
并且它只接受数字作为值,所以 tabIndex={0}
应该可以解决问题